microsoft / microsoft/TypeScript
Too wide diagnostic with array spread
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
array spread, diagnostics
🕗 Version & Regression Information
- This is the behavior in every version I tried and I have reviewed the FAQ
⏯ Playground Link
💻 Code
type Abc = "a" | "b" | "c";
const array1: Abc[] = ["a", "b"];
const array2: Abc[] = [
...array1,
"a",
"b",
"d",
]
🙁 Actual behavior
The whole contents of array2 is highlighted in red.
🙂 Expected behavior
Only the "d" should be highlighted in red, as it is the only incorrect part of array2. Note that if we remove the spread ...array1, then it works as expected.
Additional information about the issue
With more complicated types/data, this bug can make it pretty hard to diagnose where the problem is.
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 with the linked TypeScript Playground reproduction and the array-spread example in the issue. Trace how diagnostics are produced for the array literal, then verify that only the "d" element is highlighted while the spread and valid elements are not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100