TypeScript · Senior · Question 39 of 75

How do you enable type checking in JS files without migrating to TS?

Explanation

TypeScript understands JSDoc: /** @param {string} name */, @type, @typedef, and type imports via @import. Many JS libraries are typed this way, and it enables gradual migration. Checking works in the editor and via tsc --noEmit.

Further reading

Problem with a question

TypeScript · Senior · question 39

Test yourself

Take the TypeScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz