Certain edge cases may force you to skip type-checking. The following lists the different ways a code line, file, component, or package, can be ignored by Typescript's type-checking.
Typescript is set, by default, to allow for JS files ("allowJs": true
) in your components, but to skip type-checking in those files ("checkJs": false
).
These default configurations can be utilized to ignore an entire file as well as its dependencies.
For example:
// @filename: my-component.js // this dependency will, not be type-checked import mongoose from 'mongoose'; // this will not be type-checked mongoose .connect('mongodb://127.0.0.1:27017/test') .then(() => console.log('Connected!'));
Inline 'ignore' comments can also be used to ignore type-checking.
The following skips type-checking of specific lines of code:
/* @ts-ignore */ import mongoose from 'mongoose'; /* @ts-ignore */ mongoose .connect('mongodb://127.0.0.1:27017/test') .then(() => console.log('Connected!'));
The following skips type-checking of the entire file:
/* @ts-nocheck */ import mongoose from 'mongoose'; mongoose .connect('mongodb://127.0.0.1:27017/test') .then(() => console.log('Connected!'));
Set your Typescript configuration to skip the type-checking of deceleration any file that is not specifically referred to by your components.
// @filename: my-env/config/tsconfig.json { "extends": "@teambit/react.react-env/config/tsconfig.json", "include": ["**/*", "**/*.json"], "compilerOptions": { "skipLibCheck": true } }
To learn more see Typescript's official documentation.