Introduction

Sometimes in a project one would wish to disable TypeScript type checking, possibly because of a JavaScript to TypeScript migration or any other reason. Let’s see how to turn off TypeScript typechecking:

Turning off TypeScript checking for a file

To turn off TypeScript checking for a file, add @ts-nocheck at the top of the file:

// @ts-nocheck
const { Command } = require('commander');
const jsbgl = require('../jsbgl/src/jsbgl');
const utils = require('../utils')

@ts-nocheck turns off checking for the entire file

Turn off TypeScript check on a single line:

To turn off TypeScript checking for a single line, add @ts-ignore at the top of the file:

// @ts-ignore
const { Command } = require('commander');

@ts-ignore disables TypeScript checking for the preceeding line below.

To learn more about TypeScript, check this out


Found this article helpful? You may follow me on Twitter where I tweet about interesting topics on software development.