如何使 React Native CLI 因 TypeScript 错误而失败?
const getCatOfTheDay = (cat: string) => `Cat of the day: ${cat}`;
getCatOfTheDay(123);
这应该会抛出一个 TypeScript 错误
Argument of type 'number' is not assignable to parameter of type 'string'.ts(2345)
但我的 npm start
只是继续工作并且不会抛出任何错误。
我的tsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react-native",
"module": "commonjs",
"noEmit": true,
"noEmitOnError": true,
"strict": true,
"target": "ES2020"
}
}
使用 react-native 0.62