microsoft / microsoft/TypeScript

URLSearchParams/Headers constructor also receives iterables including Map

Open
#19,806 2 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

TypeScript Version: master

Code

new Headers(new Map([['abc', 'bcd']])).get('abc')
new Headers({ [Symbol.iterator]() { return new Map([['abc', 'bcd']]).entries() } }).get('abc')

Expected behavior: Both returns bcd so should pass without errors

Actual behavior: 'not assignable' error

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 locating the standard library declarations for Headers and URLSearchParams and checking how their constructor inputs are typed. Compare those declarations with the iterable and Map examples in the issue, then run the relevant compiler or declaration tests; done means both examples type-check without errors and preserve the expected value.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.