Skip to content

[TypeScript] Add missing Headers methods #43279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

retyui
Copy link
Contributor

@retyui retyui commented Mar 1, 2024

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