microsoft / microsoft/TypeScript

Mixing Iterable destruction with plain args when calling function

Open
#42,119 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: check: Type Inference
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Bug Report

🔎 Search Terms
🕗 Version & Regression Information
  • This changed between versions 3.3.3333 and 3.5.1
⏯ Playground Link

Playground link with relevant code

💻 Code

// no errors, wrong
new Set(...new Set<string>([]), '34')
new Set(...new Set<string>(['12']), '34')

// error, ok
new Set('12', '34')
🙁 Actual behavior

Code accepted as valid

🙂 Expected behavior

Error thrown

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 and reproduce the two accepted new Set(...new Set<string>(...), '34') calls alongside the rejected plain-argument case. Trace the checker entry point for constructor calls with iterable spreads, then add a regression test covering the reported forms and verify that invalid calls are rejected.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.