Skip to content

[TypeScript] Add missing Headers methods#43279

Closed
retyui wants to merge 1 commit into
facebook:mainfrom
retyui:feat/retyui/update-headers-global-type
Closed

[TypeScript] Add missing Headers methods#43279
retyui wants to merge 1 commit into
facebook:mainfrom
retyui:feat/retyui/update-headers-global-type

Conversation

@retyui

@retyui retyui commented Mar 1, 2024

Copy link
Copy Markdown
Contributor

Summary:

// 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

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

Test Plan:

Use code above in your RN project and run yarn tsc --noEmit

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Mar 1, 2024
@retyui retyui changed the title [TypeScript] Add missing Header methods [TypeScript] Add missing Headers methods Mar 1, 2024
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@arushikesarwani94 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 6, 2024
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@arushikesarwani94 merged this pull request in 0286151.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants