TypeScript · Senior · Question 39 of 75
How do you enable type checking in JS files without migrating to TS?
- ✓Correct answer:
// @ts-checkand types via JSDoc - 2Rename the file to
.jsxor.mjs - 3It's impossible without the
.tsfile extension
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.