2

How can I make the React Native CLI fail on a TypeScript error?

    const getCatOfTheDay = (cat: string) => `Cat of the day: ${cat}`;
    getCatOfTheDay(123);

This should throw a TypeScript error

Argument of type 'number' is not assignable to parameter of type 'string'.ts(2345)

but instead my npm start does just continue working and doesn't throw any error.

My tsconfig.json

{
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "forceConsistentCasingInFileNames": true,
        "jsx": "react-native",
        "module": "commonjs",
        "noEmit": true,
        "noEmitOnError": true,
        "strict": true,
        "target": "ES2020"
    }
}

Using react-native 0.62

Sir hennihau
  • 1,495
  • 4
  • 18
  • 31
  • 1
    @GuilhermeSantiago Not really. I was reading it up in another place some time ago, but dont remember everything. Most important what I remember is that the build process won't fail for react native, a good approach would be to run type checks in your ci cd pipeines to determine falsy typescript. – Sir hennihau Oct 29 '22 at 18:14

0 Answers0