React Native:构建不会因 TypeScript 错误而失败

时间:2021-07-11 13:07:05

标签: typescript react-native react-native-cli

如何使 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

0 个答案:

没有答案