The require Keyword in TypeScript (import = require, TS2591, ESM)
The require keyword in TypeScript is really Node.js’s CommonJS require() function: it loads a module synchronously and returns its exports. In a .ts file it needs Node’s types, and it returns any, so prefer import x = require() or plain import: Every example here ran on TypeScript 7.0.2 and Node.js v22.22.2, compiled in strict mode. … Read more >>









