Repository navigation
Migrate Fabric spec imports to the public React Native API #3074
Description
Description
react-native-svg@15.15.5 uses private React Native imports in its Fabric specifications and generated declarations. The current upstream specifications still contain these imports.
React Native introduced its Strict TypeScript API in 0.80 and enabled it by default in 0.87. Under this API, private deep-import paths are not available for TypeScript resolution. React Native documents public package-root exports for Codegen types and helpers as the supported replacements.
Affected imports
For example, src/fabric/CircleNativeComponent.ts contains:
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type {
DirectEventHandler,
Float,
Int32,
WithDefault,
} from 'react-native/Libraries/Types/CodegenTypes';Other Fabric specifications use the same private Codegen imports, including additional types such as Double. Published declarations also reference private Codegen types and codegenNativeComponent's NativeComponentType.
Steps to reproduce
- Clone the minimal reproduction repository linked below.
- Run
yarn install. - Run
yarn typecheck. - Observe TypeScript error
TS7016forreact-native/Libraries/Types/CodegenTypesinsrc/CircleNativeComponent.ts. The fixture extracts the private-import pattern from the upstreamCircleNativeComponent.ts;skipLibCheckremains enabled. - Run
yarn typecheck:fixed. The equivalent fixture using public React Native exports passes.
Snack or a link to a repository
Minimal reproduction repository
SVG version
15.15.5
React Native version
0.87.1
Platforms
Android, iOS, macOS, Web. This is a TypeScript resolution issue; no device or native build is required.
Suggested change
Use public package-root exports:
import type { CodegenTypes } from 'react-native';
import { codegenNativeComponent } from 'react-native';Update annotations to the corresponding CodegenTypes.* members, preserving existing native signatures and defaults. Replace private NativeComponentType references in the generated declarations with the appropriate public component type.
Please cover all affected Fabric specifications and their shared types, then regenerate the published TypeScript declarations and runtime build artifacts. Account for the library's supported React Native versions when deciding whether a minimum-version change is needed.
Scope and compatibility
- Scope: TypeScript/Codegen import compatibility, not a rendering or platform-specific runtime failure.
skipLibCheckcan suppress errors in dependency declarations, but does not migrate the imports or suppress errors when raw TypeScript specifications are included in a consumer's compilation.- The reproduction typechecks a source fixture using the same private-import pattern as the upstream Fabric specification; it is not a native app or device-level repro.
Related issues
Issue #2829 reported failure to resolve react-native-svg itself and was closed after the reporter identified a lockfile/resolutions problem. This request concerns private imports from React Native inside SVG's specifications, rather than resolution of the SVG package.
References:
- React Native Strict TypeScript API and Codegen migration guide
- Equivalent public-import migration proposed for react-native-safe-area-context
- Equivalent merged migration in react-native-view-shot
Acknowledgements
Searched open and closed issues and pull requests for matching import-migration reports before filing.
AI disclosure: GitHub Copilot assisted with researching and drafting this issue
Activity