microsoft / microsoft/TypeScript
is out-of-bounds in tuple of length,but the introduction in the document can be out of bounds
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.2.0
Code
This is the official demo
// Declare a tuple type
let x: [string, number];
// Actually,this code will throw error
x[3] = 'world'; // OK, 'string' can be assigned to 'string | number'
Expected behavior:
I want to know if this is a bug or this is document error
Actual behavior:
Tuple out of bounds will trow error, but document say When accessing an element outside the set of known indices, a union type is used instead

Related Issues: NO
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the tuple access and assignment behavior in the linked TypeScript Playground, then compare it with the official documentation passage quoted in the issue. Update the documentation to accurately explain out-of-bounds tuple access and verify that the example no longer suggests the assignment is valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100