react-native-css/metro's declarations import react-native, loading React Native's globals into a Node program
维护者通常 5 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 70/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- node.js, react-native, typescript
- 领域
- tooling
调研方向
从 src/compiler/compiler.types.ts(第 8 行)和 src/native/reactivity.ts(第 1-8 行)开始,查看 VAR_SYMBOL 引入 react-native 的导入。运行 repro 的 npx tsc -p .,使用 skipLibCheck: false 来确认 72 个错误。修复方法是阻止类型声明从 native 侧导入运行时常量,然后验证 metro.config.ts 在没有 React Native globals 的情况下通过类型检查。
由索引模型根据 Issue 内容生成。
描述
Before submitting a new issue
- I tested using the latest version of the library, as the bug might be already fixed.
- I tested using a supported version of react native.
- I checked for possible duplicate issues, with possible answers.
Bug summary
Typing a Metro config through react-native-css/metro (or nativewind/metro) loads React Native's types into a Node program. The compiler's declarations import a runtime constant from the native side: src/compiler/compiler.types.ts imports VAR_SYMBOL from ../native/reactivity, and src/native/reactivity.ts imports from react-native. React Native's declarations bring its runtime globals (fetch, AbortController, Blob, require…), which clash with @types/node's, so a metro.config.ts checked with skipLibCheck: false fails.
Library version
0.0.0-nightly.2421ea7 (main at 2421ea77da52), and 3.1.0-rc.0
Environment info
Windows 11 10.0.26300, Node 26.12.1, npm 12.2.1, TypeScript 7.0.2, @types/node 26.6.6, react-native 0.88.1.
No app or native build is involved: the errors come from the type check alone.
Steps to reproduce
- Clone the reproducible example: a
metro.config.tsholding onlyimport type {} from 'react-native-css/metro';, checked by atsconfig.jsonwith"types": ["node"]andskipLibCheck: false, besidereact-native0.88.1 andreact-native-css0.0.0-nightly.2421ea7. npm install --ignore-scriptsnpx tsc -p ., thennpx tsc -p . --explainFilesto see whyreact-nativeis in the program.
Expected: no error; a Metro config's types reach no React Native type.
Actual: 72 errors in Node's and React Native's globals. The first ones:
node_modules/@types/node/module.d.ts(711,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.
node_modules/@types/node/web-globals/abortcontroller.d.ts(43,15): error TS2300: Duplicate identifier 'AbortController'.
node_modules/@types/node/web-globals/abortcontroller.d.ts(44,9): error TS2300: Duplicate identifier 'AbortController'.
node_modules/@types/node/web-globals/abortcontroller.d.ts(50,15): error TS2300: Duplicate identifier 'AbortSignal'.
node_modules/@types/node/web-globals/abortcontroller.d.ts(51,9): error TS2300: Duplicate identifier 'AbortSignal'.
and --explainFiles shows where React Native comes from:
node_modules/react-native/types_generated/index.d.ts
Imported via "react-native" from file 'node_modules/react-native-css/dist/typescript/module/src/native/reactivity.d.ts' with packageId 'react-native/types_generated/[email protected]+@types/[email protected][email protected]'
Reproducible example repository
https://github.com/YevheniiKotyrlo/react-native-css-metro-types-react-native
- 主要语言
- TypeScript
- 星标
- 166
- 派生
- 45
- 平均合并
- 10 天 1 小时
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nativewind/react-native-css 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
nativewind/react-native-css#554 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
nativewind/react-native-css#548 · 2 条评论 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
nativewind/react-native-css#545 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
nativewind/react-native-css#544 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
nativewind/react-native-css#543 ·
维护者通常 5 天内回复
查看 nativewind/react-native-css 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 74/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
remotion-dev/remotion#12905 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
supermomonga/paseo-plugin-zcode-provider#83 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
oxidecomputer/skepsis#102 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
voidzero-dev/void#677 ·
维护者通常 1 天内回复