【发布时间】:2022-01-16 16:57:12
【问题描述】:
我将 React Native 项目与官方文档一起运行,并将 TypeScript 添加到项目中。 我在执行 'yarn tsc' 时出现了很多 ESlint 错误,例如:
App.tsx:10:14 - error TS2305: Module '"react"' has no exported member 'Node'.
10 import type {Node} from 'react';
我知道这只是一个TS错误,但我很困惑,为什么代码'import type {Node} from 'react';'会产生这个错误
tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react-native",
"lib": ["es2017"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext"
},
"exclude": [
"node_modules",
"babel.config.js",
"metro.config.js",
"jest.config.js"
]
}
【问题讨论】:
标签: reactjs typescript react-native