Skip to content

fix(types): incorrect <void> use in typescript#1608

Open
nickhudkins wants to merge 1 commit intofacebook:mainfrom
nickhudkins:type-fixes
Open

fix(types): incorrect <void> use in typescript#1608
nickhudkins wants to merge 1 commit intofacebook:mainfrom
nickhudkins:type-fixes

Conversation

@nickhudkins
Copy link
Contributor

@nickhudkins nickhudkins commented Nov 7, 2025

Summary

The use of void as a type parameter is semantically different in TS than Flow. Specifically, providing void in Flow will result in the use of the default type parameter value, while TS will treat it as an explicit use of void for the generic.

Original Issue: #1491

Changelog:
[Fix] Bundler types (transformFile)
[Fix] IncrementalBundler types (OutputGraph, getDeltaBundler, getDependencies, buildGraph, initializeGraph and updateGraph)
[Fix] Worker types (transform)
[Fix] Metro.buildGraph return type

Test plan

Oof. This may be a larger discussion as keeping the TS and Flow types in-sync and correct may be a moving target as the project evolves. For now, the verification is "when consuming this code in a TS codebase, types are the same as if I was consuming the flow annotated code"

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 7, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 7, 2025
@robhogan
Copy link
Contributor

robhogan commented Nov 7, 2025

Thanks @nickhudkins!

Several Metro packages do now have automatic TS types, but there are a few patterns unsupported by the translator and/or TS itself so we've been refactoring and touching up package-by-package to get translations working (any PRs to get us closer would be appreciated as well!). metro-config for example is automatic and validated in CI, but metro isn't.

https://github.com/facebook/metro/blob/main/scripts/generateTypeScriptDefinitions.js#L29

@nickhudkins
Copy link
Contributor Author

I actually saw this and began down the path of doing type generation for metro, let me see if I can take an incremental approach here!

@nickhudkins
Copy link
Contributor Author

Alrighty... metro types are gonna take some more significant work, especially just trying to reconcile flow types with typescript, especially those that have spreads at the end

meta-codesync bot pushed a commit that referenced this pull request Nov 12, 2025
Summary:
As I began working to hand-fix some types, the formidable robhogan [pointed me](#1608 (comment)) in the direction of `generateTypeScriptDefinitions.js`, which has been used here to generate types for `metro-transform-worker`

Changelog:
[Internal]: Auto generate types for `metro-transform-worker`

Pull Request resolved: #1610

Test Plan: Automatically tested in CI, also peformed a good-ol eyeball check.

Reviewed By: motiz88, robhogan

Differential Revision: D86662805

Pulled By: vzaidman

fbshipit-source-id: 2e8cc43863b5285976a0759e0c1881b202e1aebc
nickhudkins added a commit to nickhudkins/metro that referenced this pull request Nov 13, 2025
…k#1610)

Summary:
As I began working to hand-fix some types, the formidable robhogan [pointed me](facebook#1608 (comment)) in the direction of `generateTypeScriptDefinitions.js`, which has been used here to generate types for `metro-transform-worker`

Changelog:
[Internal]: Auto generate types for `metro-transform-worker`

Pull Request resolved: facebook#1610

Test Plan: Automatically tested in CI, also peformed a good-ol eyeball check.

Reviewed By: motiz88, robhogan

Differential Revision: D86662805

Pulled By: vzaidman

fbshipit-source-id: 2e8cc43863b5285976a0759e0c1881b202e1aebc
meta-codesync bot pushed a commit that referenced this pull request Jan 26, 2026
Summary:
As I began working to hand-fix some types, the formidable robhogan [pointed me](#1608 (comment)) in the direction of `generateTypeScriptDefinitions.js`, which has been used here to generate types for `metro-file-map`

Changelog:
[Fix]: Auto generate types for `metro-file-map`

Pull Request resolved: #1611

Test Plan: Automatically tested in CI, also peformed a good-ol eyeball check.

Reviewed By: vzaidman

Differential Revision: D90583383

Pulled By: robhogan

fbshipit-source-id: 626c8fc63407b6d9aa7cb18993ad1096455bd202
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. 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.

3 participants