We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
RequestInit
headers
HeadersInit
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)).
Headers
RequestInit.headers
Also HeadersInit is not used in RequestInit.
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
Expected behavior:
No errors.
Actual behavior:
Error:
According the spec
RequestInitmay hasheadersprop asHeadersInittype which isBut currently we have
Headersinstead of map object inRequestInit.headers(the code above works fine in all browsers (including Edge)).Also
HeadersInitis not used inRequestInit.