I ran the React Native project along with the official documentation and added TypeScript to the project. Many ESlint errors occurred when I was executing 'yarn tsc', for example:
App.tsx:10:14 - error TS2305: Module '"react"' has no exported member 'Node'.
10 import type {Node} from 'react';
I know this is just an TS error, but I am confused, why does the code, 'import type {Node} from 'react';', produce this error
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"
]
}
CodePudding user response:
try to add in tsconfig.json
"skipLibCheck": true,
CodePudding user response:
Because React doesn't export a type named Node
. Maybe you are looking for ReactNode
?
import type {Node} from 'react'; // error
import type {ReactNode} from 'react'; // ok