You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
importscrollIntoViewfrom'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:
importscrollIntoViewfrom'smooth-scroll-into-view-if-needed';scrollIntoView.default(el);// TypeError: scrollIntoView.default is not a function
The 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.
The text was updated successfully, but these errors were encountered:
With
"moduleResolution": "NodeNext"
intsconfig.json
, typescript incorrectly assumes the type of exports ofsmooth-scroll-into-view-if-needed
, because it thinks/typings/index
defines types for a commonjs module.This works at runtime but doesn't compile:
This compiles but breaks at runtime:
The way I managed to fix it is to patch
smooth-scroll-into-view-if-needed
'spackage.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.The text was updated successfully, but these errors were encountered: