TS2834
Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
Broken Code ❌
import MyClass from './MyClass';Solution:
This error occurs because, with moduleResolution set to node16 or nodenext, TypeScript requires explicit file extensions in import paths for ECMAScript modules to ensure compatibility with Node.js's resolution mechanism. Add the explicit file extension to fix the import path.
Fixed Code ✔️
import MyClass from './MyClass.js';