-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Description
Describe the bug
Getting
main.ts:1:26 - error TS7016: Could not find a declaration file for module '@js-temporal/polyfill'. '.../node_modules/@js-temporal/polyfill/dist/index.cjs' implicitly has an 'any' type.
when trying to import in a project with moduleResolution: node16
.
To Reproduce
package.json
{
"dependencies": {
"@js-temporal/polyfill": "^0.4.2",
"typescript": "4.7.4"
}
}
tsconfig.json
{
"compilerOptions": {
"moduleResolution": "Node16",
"noImplicitAny": true
}
}
main.ts
import { Temporal } from '@js-temporal/polyfill';
and then run:
tsc
Output I get:
$ tsc
main.ts:1:26 - error TS7016: Could not find a declaration file for module '@js-temporal/polyfill'. '.../node_modules/@js-temporal/polyfill/dist/index.cjs' implicitly has an 'any' type.
Try `npm i --save-dev @types/js-temporal__polyfill` if it exists or add a new declaration (.d.ts) file containing `declare module '@js-temporal/polyfill';`
1 import { Temporal } from '@js-temporal/polyfill';
~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in main.ts:1
Additional context
My intent in this example is to import Temporal using require, and this is what's happening, but typescript doesn't seem to pick up the .d.ts
file.
Typescripts esm support is not without controversies. One of them is that they are more strict about the location of .d.ts
files: microsoft/TypeScript#49160 . The most straightforward solution seems to be moving and duplicating index.d.ts
to dist/index.d.cts
, dist/index.esm.d.ts
and dist/index.umd.d.ts
, but there might be better ways I am not aware of.
Metadata
Metadata
Assignees
Labels
No labels