Closed
Description
Bug Report
๐ Search Terms
NodeNext, esm, CJS, cli-spinners
๐ Version & Regression Information
- This only occurs in nightly builds.
- I was unable to test this on prior versions because
nodenext
is only supported in the nightly versions.
โฏ Playground Link
From what I can tell you can't install npm modules in the playground, so I made a repro on StackBlitz: https://stackblitz.com/edit/node-opvt9e?file=index.ts run npm run typecheck
in the console to see the issue.
๐ป Code
import spinners from 'cli-spinners';
console.log(spinners);
๐ Actual behavior
TypeScript cannot find the typings for cli-spinners
which is a CJS module. It does not use a main
or exports
or types
field in the package.json
, it just includes a index.js
and index.d.ts
file.
index.ts:1:22 - error TS2307: Cannot find module 'cli-spinners' or its corresponding type declarations.
1 import spinners from 'cli-spinners';
~~~~~~~~~~~~~~
Found 1 error in index.ts:1
๐ Expected behavior
New NodeNext
module behaviour to import CJS as it used to. E.g looking at index.d.ts
if there is no main
field. https://www.typescriptlang.org/docs/handbook/module-resolution.html#how-typescript-resolves-modules