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
It is not possible to import any type exported internally from the lib directory when your TS project is set to any of the modern values of moduleResolution: "Node16", "NodeNext" or "Bundler"
Explanation
The reason for that is filename clash between ./dist/lib.js and ./dist/lib/ directory -- modern resolution algorithms resolve the './lib' in
export*from'./lib'
in the ./dist/index.d.ts file to the ./dist/lib.js , not ./dist/lib/index.d.ts, because that's how the Node resolution algorithm works (lib.js has a higher precedence than lib/index.js).
The quickest way to resolve the issue is to change the lib.js filename to something like lib.web.js, so that there is no confusion between the file name and the directory name.
Reproduction
Prerequisites
A TS Project with a compilerOption "moduleResolution" set to "Node16", "NodeNext" or "Bundler"
Module '"casper-js-sdk"' has no exported member 'DeployUtil'
Screenshots
Additional context
The bug does not have any runtime implications, but it's not possible to import the library correctly in projects relying on current TypeScript defaults.
Defect Type
Regression
New
Escape
The text was updated successfully, but these errors were encountered:
A workaround for Node devs is to remove the dist/lib.js file from the package after installation -- Node is going to import dist/lib.node.js, as defined in package.json#node, and TypeScript will start resolving import from ./lib to dist/lib/index.d.ts.
Description
It is not possible to import any type exported internally from the
lib
directory when your TS project is set to any of the modern values ofmoduleResolution
:"Node16"
,"NodeNext"
or"Bundler"
Explanation
The reason for that is filename clash between
./dist/lib.js
and./dist/lib/
directory -- modern resolution algorithms resolve the'./lib'
inin the
./dist/index.d.ts
file to the./dist/lib.js
, not./dist/lib/index.d.ts
, because that's how the Node resolution algorithm works (lib.js
has a higher precedence thanlib/index.js
).The quickest way to resolve the issue is to change the
lib.js
filename to something likelib.web.js
, so that there is no confusion between the file name and the directory name.Reproduction
Prerequisites
"moduleResolution"
set to"Node16"
,"NodeNext"
or"Bundler"
Steps to reproduce
Expected behavior
The import is correct.
Actual behavior
TypeScript error 2305:
Screenshots
Additional context
The bug does not have any runtime implications, but it's not possible to import the library correctly in projects relying on current TypeScript defaults.
Defect Type
The text was updated successfully, but these errors were encountered: