简体   繁体   中英

Disable type checking from all .tsx files

I'm trying to prevent type checking from my typescript project as it's still under development. I tried adding "checkJs": false in my tsconfig file but still type checking triggers. Only solution i found was to add // @ts-nocheck in every file of my project. Is there a way to disable type checking without having to add // @ts-nocheck to every single file and instead use it in a single place.

my tsconfig.json file

{
  "compilerOptions": {
    "target": "es5",
    "checkJs": false,
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noEmit": true,
    "jsx": "preserve",
    "isolatedModules": true
  },
  "include": [
    "src"
  ]
}

create .eslintrc.js in your root to ignore what you want or config your eslint . please read the docs , there are many rules in there. your case:

module.exports = {
  extends: ["react-app", "plugin:prettier/recommended"],
  rules: {
     "@typescript-eslint/ban-ts-ignore": "off"
  },
  plugins: ["react", "@typescript-eslint", "prettier"]
};

to igore type check

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM