-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make splice deleteCount
required in es5.d.ts
#32643
make splice deleteCount
required in es5.d.ts
#32643
Conversation
In ES5 `deleteCount` is not an optional argument. If it is not provided it defaults to 0 as a side effect of `undefined` being converted to an integer. In ES6 `deleleteCount` is optional, and it defaults to the length of the array minus the start index. If you are targeting ES5 but don't provide `deleteCount` the behaviour will be different depending on the environment your build is running in. fixes microsoft#32638
af0fe7d
to
368d007
Compare
@typescript-bot test this |
Heya @RyanCavanaugh, I've started to run the parallelized community code test suite on this PR at 368d007. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya @RyanCavanaugh, I'm starting to run the extended test suite on this PR at 368d007. Hold tight - I'll update this comment with the log link once the build has been queued. |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
@weswigham looks like some noise in the user suite diff - can you check in on it? |
Anything I can do to help here? |
@RyanCavanaugh @weswigham any update? |
I brought this back up to date with master |
Thanks for your patience on this! |
This caused a break const arr: string[] = [];
const boundSplice = arr.splice.bind(arr, 0, 0);
const items: string[] = [];
// Used to be OK, now an error
boundSplice.apply(arr, items); |
@RyanCavanaugh it's OK in ES6, it's not OK in ES5 (altho there may have been pre-ES6 browsers that considered it optional). is that a type error when targeting ES6? |
It's incorrectly a type error right now against ES6 |
This reverts commit ddcf139.
Shame this is getting reverted. We had an outage on our TV app which this would have caught if it had existed. A few TV’s are still way back in the past. |
Do you know why it caused |
@RyanCavanaugh so does that mean this PR needed to also override it in ES6 to make it optional? |
@tjenkinson I believe it's because under |
Ok thanks for the explanation. It’s a shame but not the end of the world because |
@DanielRosenwasser it seems like fixing the underlying flaws with overloads is a pretty important thing to address :-/ |
I agree, but I don't think we have anything concrete that we feel good about yet. |
) This reverts commit ddcf139.
In ES5
deleteCount
is not an optional argument. If it is not provided it defaults to 0 as a side effect ofundefined
being converted to an integer.https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.12
In ES6
deleleteCount
is optional, and it defaults to the length of the array minus the start index.https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.splice
If you are targeting ES5 but don't provide
deleteCount
the behaviour will be different depending on the environment your build is running in.This PR makes the
deleteCount
required when targeting ES5 but should allow it to be optional for ES6.fixes #32638
The Issue
When running in ES5
When running in ES6