microsoft / microsoft/TypeScript

`deleteCount` param to `splice()` is not optional in es5 types

Open
#32,638 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: lib.d.ts
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 3.5.1

Search Terms: splice deleteCount

Code
Set the target to ES5 then

[1, 2, 3].splice(0); // should error. deleteCount missing
[1, 2, 3].splice(0, 3); // ok

Expected behavior:
[1, 2, 3].splice(0); not allowed

Actual behavior:
[1, 2, 3].splice(0); allowed

Playground Link: this

deleteCount only become optional in ES6

ES5: https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.12
ES6: https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.splice

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example in the TypeScript Playground with the target set to ES5, then compare the ES5 and ES6 declarations for Array.splice. The fix is complete when ES5 rejects an omitted deleteCount while ES6 continues to allow it.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.