Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

lib.d.ts has a wrong definition of HeadersInit #19656

Copy link
Copy link
@timocov

Description

@timocov
Issue body actions

TypeScript Version: 2.6.1 (and 2.7.0-dev.20171101)

Code

https://www.typescriptlang.org/play/index.html#src=fetch(%27%2Fsome-url%27%2C%20%7B%20headers%3A%20%7B%20%27Some-Header-Name%27%3A%20%27Value%27%20%7D%20%7D)%3B

fetch('/some-url', { headers: { 'Some-Header-Name': 'Value' } });

Expected behavior:
No errors.

Actual behavior:
Error:

Object literal may only specify known properties, and ''Some-Header-Name'' does not exist in type 'Headers | string[][]'.

According the spec RequestInit may has headers prop as HeadersInit type which is

type HeadersInit = [string, string][] | { [key: string]: string };

But currently we have Headers instead of map object in RequestInit.headers (the code above works fine in all browsers (including Edge)).

Also HeadersInit is not used in RequestInit.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.