Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types to exports/./import to support Typescript Node16 #158

Merged
merged 1 commit into from
Jun 1, 2022

Conversation

jonasb
Copy link
Contributor

@jonasb jonasb commented May 31, 2022

Before this Typescript would fail to resolve the types for the package when configured to use module: "Node16" (new in Typescript 4.7).

main.ts:1:26 - error TS7016: Could not find a declaration file for module '@js-temporal/polyfill'.

Repro available at https://github.com/jonasb/typescript-error-repro/tree/typescript-4.7-esm-node16-js-temporal

Before this Typescript would fail to resolve the types for the package.

main.ts:1:26 - error TS7016: Could not find a declaration file for module '@js-temporal/polyfill'.
@12wrigja
Copy link
Contributor

Thanks for the PR, and for creating a repro.

Looking around the community, this seems like it's unfortunately intentional (microsoft/TypeScript#46334 (comment) implies that if there is an exports object that a types key is now required in the exports object instead of falling back to the top-level types). Seems similar to motiondivision/motion#1543.

I patched your PR and tested against a couple small test projects and they seem to compile/run just fine, so I think this is fine to merge.

@12wrigja 12wrigja merged commit 304c86d into js-temporal:main Jun 1, 2022
@everett1992
Copy link

I hit Could not find a declaration file for module '@js-temporal/polyfill' today and this change fixes the error. When will this be published to npm?

@12wrigja
Copy link
Contributor

I've been in the middle of merging a bunch of upstream fixes, but that might take longer to release so I'll put together a patch release with this fix sometime in the next day or so.

@12wrigja
Copy link
Contributor

12wrigja commented Jul 19, 2022

This should now be published on NPM: https://www.npmjs.com/package/@js-temporal/polyfill/v/0.4.2

@everett1992 mind confirming this fixes things for you?

@12wrigja
Copy link
Contributor

12wrigja commented Aug 4, 2022

@jonasb it seems this might not have fixed things, based on the report in #177 ? Can you verify that this PR did fix things for your repro?

@everett1992
Copy link

everett1992 commented Aug 9, 2022

I can confirm it's fixed for my use case - using "type": "module" and native esm. #177 sounds like an issue with commonjs require..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants