-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
With "moduleResolution": "NodeNext" in tsconfig.json, typescript incorrectly assumes the type of exports of smooth-scroll-into-view-if-needed, because it thinks /typings/index defines types for a commonjs module.
This works at runtime but doesn't compile:
import scrollIntoView from 'smooth-scroll-into-view-if-needed';
scrollIntoView(el); // Type 'typeof import("node_modules/smooth-scroll-into-view-if-needed/typings/index")' has no call signatures.This compiles but breaks at runtime:
import scrollIntoView from 'smooth-scroll-into-view-if-needed';
scrollIntoView.default(el); // TypeError: scrollIntoView.default is not a functionThe way I managed to fix it is to patch smooth-scroll-into-view-if-needed's package.json with "type": "module", so typescript knows to treat /typings/index as an es module. But I'm not sure if that's a proper solution, since I'm still trying to wrap my head around this whole typescript node esm disaster.
Metadata
Metadata
Assignees
Labels
No labels