Support importing types across Turbo Module specs (#56045)#56045
Open
christophpurrer wants to merge 1 commit intofacebook:mainfrom
Open
Support importing types across Turbo Module specs (#56045)#56045christophpurrer wants to merge 1 commit intofacebook:mainfrom
christophpurrer wants to merge 1 commit intofacebook:mainfrom
Conversation
|
@christophpurrer has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95646987. |
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Mar 15, 2026
Summary: ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. - The flow-schema OTA safety tool is updated to build imported types from its existing import map infrastructure and pass them to the codegen parser. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
c8dd3b4 to
74f75a6
Compare
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Apr 18, 2026
Summary: ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. - The flow-schema OTA safety tool is updated to build imported types from its existing import map infrastructure and pass them to the codegen parser. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
73b65ec to
cae92f8
Compare
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Apr 20, 2026
Summary: ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. - The flow-schema OTA safety tool is updated to build imported types from its existing import map infrastructure and pass them to the codegen parser. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Apr 20, 2026
Summary: ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
145868f to
0a5f820
Compare
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Apr 21, 2026
Summary: ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Apr 21, 2026
Summary: ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
0a5f820 to
943eb05
Compare
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Apr 21, 2026
Summary: Pull Request resolved: facebook#56045 ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
943eb05 to
070f910
Compare
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Apr 21, 2026
Summary: Pull Request resolved: facebook#56045 ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
070f910 to
ea919f1
Compare
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Apr 22, 2026
Summary: ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
ea919f1 to
de38c0a
Compare
Summary: Pull Request resolved: facebook#56045 ## Changelog: [General] [Added] - Add cross-file type import support for React Native Turbo Module codegen Turbo Module JavaScript specs previously required all types (enums, type aliases) to be defined in the same file. This forced developers to duplicate type definitions when sharing them across multiple modules. This diff adds an optional `importedTypes` parameter to `parseString()` that allows the parser to resolve types defined in external files. The approach: - `parseString()` accepts an optional `TypeDeclarationMap` of imported types, which are merged with local types (local definitions take precedence). - `parseFile()` automatically resolves relative `import type` declarations by parsing the source files and extracting their type AST nodes. - A shared `resolveImportedTypes()` utility handles filesystem resolution for both Flow and TypeScript parsers. - `getImportsFromAST()` extracts type-only import declarations from the AST, filtering out value imports to avoid unnecessary filesystem I/O. Code generators require zero changes since they consume the flat schema (enumMap/aliasMap), and imported types produce identical schema entries to file-local types. Differential Revision: D95646987
de38c0a to
2736cd9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Changelog:
[General] [Added] - Add cross-file type import support for React Native Turbo Module codegen
Turbo Module JavaScript specs previously required all types (enums, type aliases)
to be defined in the same file. This forced developers to duplicate type
definitions when sharing them across multiple modules.
This diff adds an optional
importedTypesparameter toparseString()thatallows the parser to resolve types defined in external files. The approach:
parseString()accepts an optionalTypeDeclarationMapof imported types,which are merged with local types (local definitions take precedence).
parseFile()automatically resolves relativeimport typedeclarations byparsing the source files and extracting their type AST nodes.
resolveImportedTypes()utility handles filesystem resolution forboth Flow and TypeScript parsers.
getImportsFromAST()extracts type-only import declarations from the AST,filtering out value imports to avoid unnecessary filesystem I/O.
Code generators require zero changes since they consume the flat schema
(enumMap/aliasMap), and imported types produce identical schema entries to
file-local types.
Differential Revision: D95646987