v1.3.0: TypeScript issue when importing `tiny-invariant` from an CJS codebase and `"moduleResolution"` is set to `"node16"`
pkerschbaum opened this issue Β· comments
π Version & Regression Information
1.3.0
β― Playground Link
https://stackblitz.com/edit/node-cwmfq6
- Run
npm install
. - Run tsc compilation via
npm run build
. The error occurs.
Problem
If tiny-invariant
is used from an TypeScript CJS package with moduleResolution node16, this means:
"type"
inpackage.json
is not set or set tocommonjs
- and
"moduleResolution": "node16"
set intsconfig.json
...then TypeScript cannot find the types:
β― npm run build
$ tsc
src/test.ts:1:23 - error TS7016: Could not find a declaration file for module 'tiny-invariant'. '/home/projects/node-cwmfq6/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/tiny-invariant` if it exists or add a new declaration (.d.ts) file containing `declare module 'tiny-invariant';`
1 import invariant from 'tiny-invariant';
~~~~~~~~~~~~~~~~
Found 1 error in src/test.ts:1
Reason
See #150.
@pkerschbaum do you think I should deprecate 1.3.0
on npm?
Yes let's do that...
This issue has been resolved in 1.3.1
-> https://stackblitz.com/edit/node-bs8cec?file=package.json
Fixed by #150