Repository navigation
Fix yarn build-types on Windows - #59149
Draft
YevheniiKotyrlo wants to merge 1 commit into
Draft
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
Three steps in scripts/js-api/build-types read a native file path as /-separated: the default-export rename took the whole Windows path as the module name, the cyclic-import rewrite wrote backslash specifiers, and the api-extractor config embedded the temp directory unescaped. Use path.basename and path.dirname, and write the paths that land in a specifier or the config with /.
This branch has not been deployed
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:
yarn build-typesfails on Windows. Three places inscripts/js-api/build-typestreat a native file path as/-separated:replaceDefaultExportNametakes the module name fromfilePath.split('/').pop(). A Windows path has no/, so the default export is renamed to$$C:\…\ActionSheetIOS\ActionSheetIOS, and the snapshot step cannot parse the generated.d.ts(Expecting Unicode escape sequence \uXXXX).resolveCyclicImportsInDefinitiontakes the source directory the same way, and writes the rewritten import specifier withpath.join, which uses\on Windows.buildApiSnapshotpastes the temp directory intoapi-extractor.jsonas it is, so JSON reads its backslashes as escapes and api-extractor gets aprojectFolderthat does not exist.This uses
path.basenameandpath.dirname, and writes the paths that end up in an import specifier or in the config with/. On Linux and macOS the output is unchanged.Changelog:
[INTERNAL] [FIXED] - Fix
yarn build-typeson WindowsTest Plan:
main,yarn build-typesstops at the snapshot step with the parse error above. With this change it completes,packages/react-native/ReactNativeApi.d.tscomes out identical to the committed snapshot, andyarn build-types --validatepasses.replaceDefaultExportName-testnow builds its path withpath.join, so it runs with the platform's separator. On Windows it and the eightresolveCyclicImportsInDefinitioncases fail onmainand pass with this change.jest scripts/js-apipasses (161 tests) on Windows and on Linux (WSL2, Node 22.13.0), andyarn build-types --validatepasses on Linux.yarn flow-checkis clean, and so are eslint and prettier on the changed files.