Skip to content

Commit 0286151

Browse files
retyuifacebook-github-bot
authored andcommitted
Add missing Headers methods (#43279)
Summary: ```tsx // Hermes runtime (RN 73.x) console.log({...Headers.prototype}) // result: { "append": [Function anonymous], "delete": [Function anonymous], "entries": [Function anonymous], "forEach": [Function anonymous], "get": [Function anonymous], "has": [Function anonymous], "keys": [Function anonymous], "set": [Function anonymous], "values": [Function anonymous], Symbol(Symbol.iterator): [Function anonymous] } ``` But in typescript ```tsx new Headers().entries() // ^^^ Error: Property entries does not exist on type Headers Object.fromEntries(new Headers()) // ^^^ Error: Property [Symbol.iterator] is missing in type Headers but required in type Iterable<readonly any[]> ``` ## Changelog: [GENERAL] [ADDED] - [TypeScript] Add missing `Header` methods Pull Request resolved: #43279 Test Plan: Use code above in your RN project and run `yarn tsc --noEmit` Reviewed By: rshest Differential Revision: D54554523 Pulled By: arushikesarwani94 fbshipit-source-id: ae7f05f9526771ff003aaf22f786b5503661c739
1 parent 3ed0ff3 commit 0286151

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/react-native/types/modules/globals.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ declare interface Headers {
132132
get(name: string): string | null;
133133
has(name: string): boolean;
134134
set(name: string, value: string): void;
135+
entries(): IterableIterator<[string, string]>;
136+
keys(): IterableIterator<string>;
137+
values(): IterableIterator<string>;
138+
[Symbol.iterator](): IterableIterator<[string, string]>;
135139
}
136140

137141
declare var Headers: {

0 commit comments

Comments
 (0)