Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript - possible to disable type checking?

Is it possible to disable type checking when using TypeScript? I love TypeScript for classes, interface etc yet for the smaller one person projects I am normally engaged in I really don't need type checking and the pain of not finding ready made type definitions for less common libraries or the latest version of it is a pain. Thanks

like image 627
dorjeduck Avatar asked Jun 27 '15 08:06

dorjeduck


People also ask

How do I prevent TypeScript error?

Use // @ts-ignore to ignore the type checking errors on the next line in a TypeScript file. If you use a linter, you might have to add a comment to also suppress linting errors when using ts-ignore - // eslint-disable-next-line @typescript-eslint/ban-ts-comment .

Does TypeScript offer type checking?

Code written in TypeScript is checked for errors before it is executed, during compile time.

How do I disable TypeScript for a specific file?

Use the // @ts-nocheck comment to disable type checking for an entire file in TypeScript. The // @ts-nocheck comment instructs TypeScript to skip the file when type checking. If you use a linter, you might need to disable it on the line of the comment. Copied!

How do I disable TypeScript in a Project?

You could go to Tools > Options > Text Editor > JavaScript/TypeScript > Project and uncheck the Project Analysis options.


1 Answers

In TypeScript 3.7, type checking will be disabled on a file if it starts with the following comment:

// @ts-nocheck 

As already mentioned, in previous versions you can disable checking on a single line by including the following comment on the previous line:

// @ts-ignore 
like image 193
Christophe Avatar answered Sep 25 '22 17:09

Christophe