-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: ES ModulesThe issue relates to import/export style module behaviorThe issue relates to import/export style module behaviorFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
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
nodenextis 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
πͺ Related
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: ES ModulesThe issue relates to import/export style module behaviorThe issue relates to import/export style module behaviorFix AvailableA PR has been opened for this issueA PR has been opened for this issue