microsoft / microsoft/TypeScript

`Tuple & nominal` not recognised as tuple in spread parameter

Open
#45,371 8 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: Intersection
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

Nominal, Spread, Tuple,

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about spread and intersections
⏯ Playground Link

Playground link with relevant code

💻 Code
declare let a: [number, number, number] & { _nominal_a: never }
function b(...params: [number, number, number]) {}
b(...a) // Error: A spread argument must either have a tuple type or be passed to a rest parameter.
🙁 Actual behavior

The error in the code example is thrown, because TypeScript does not detect it as being a tuple.
In roblox-ts, we use a nominal marker type to indicate a special kind of tuple. This bug means that this tuple type can then not be spreaded into a fixed argument function. Our issue: https://github.com/roblox-ts/roblox-ts/issues/1537

🙂 Expected behavior

This is a tuple type, and should therefore be recognised as such.

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 with the linked TypeScript Playground example and reproduce the spread error for the intersection of a tuple and nominal marker type. Trace the tuple and spread-argument checking behavior, then add a regression test covering this case; done means the fixed-parameter call type-checks without the spread error.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.