Skip to content

Add typescript support for "exports" #439

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

Merged
merged 1 commit into from
Jul 26, 2022
Merged

Add typescript support for "exports" #439

merged 1 commit into from
Jul 26, 2022

Conversation

tarantoj-intrepid
Copy link
Contributor

Allows typescript to properly resolve the types for this package when using the new Node.js’ ECMAScript Module Support

https://www.typescriptlang.org/tsconfig#moduleResolution

Allows typescript to properly resolve the types for this package when using the new Node.js’ ECMAScript Module Support

https://www.typescriptlang.org/tsconfig#moduleResolution
@porsager porsager merged commit 3415278 into porsager:master Jul 26, 2022
@tarantoj-intrepid tarantoj-intrepid deleted the patch-1 branch July 26, 2022 08:15
@Snurppa
Copy link

Snurppa commented Sep 26, 2022

Just adding for possible error search reference, if people happen to end up here with Could not find a declaration file for module 'postgres' errors when using TypeScript NodeNext module resolution.

Error with current 3.2.4 version, without this fix merged in is:

api/src/components/db.ts:3:22 - error TS7016: Could not find a declaration file for module 'postgres'. '/Users/x/y/z/node_modules/postgres/src/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/postgres` if it exists or add a new declaration (.d.ts) file containing `declare module 'postgres';`

  import postgres from 'postgres';
                       ~~~~~~~~~~

I guess declaring declare module 'postgres' yourselves could be a solution while waiting for release, but I settled for brtual edit of node_modules/postgres/package.json and added related exports.types entry by hand.
Not production grade fix, but works for me as I am only developing locally currently.

porsager pushed a commit that referenced this pull request Feb 1, 2023
Allows typescript to properly resolve the types for this package when using the new Node.js’ ECMAScript Module Support

https://www.typescriptlang.org/tsconfig#moduleResolution
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.

4 participants