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

Declare type exports #485

Merged
merged 4 commits into from
Feb 23, 2023
Merged

Declare type exports #485

merged 4 commits into from
Feb 23, 2023

Conversation

fubhy
Copy link
Contributor

@fubhy fubhy commented Feb 23, 2023

Type exports for the connect package are currently not explicitly specified.

  • Adds explicit type exports for every entrypoint of the connect package.
  • Puts the type exports for all packages first (in accordance with the documentation: https://www.typescriptlang.org/docs/handbook/esm-node.html)
  • Removes typesVersions which shouldn't be necessary afaik (please correct me if I'm missing sth.)

@fubhy fubhy mentioned this pull request Feb 23, 2023
@timostamm
Copy link
Member

Thanks for the contrib, @fubhy ❤️

We do need the "typesVersion", unfortunately.

The repo uses "Node" module resolution, and if you run make build without "typesVersion", you'll see that failing with:

src/connect-transport.ts:47:8 - error TS7016: Could not find a declaration file for module '@bufbuild/connect/protocol'. '/Users/ts/buf/connect-es/packages/connect/protocol.js' implicitly has an 'any' type.
  If the '@bufbuild/connect' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module '@bufbuild/connect/protocol';`

47 } from "@bufbuild/connect/protocol";
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Many projects are stuck with the node module resolution algorithm. It's still used when you run create-react-app. We need to support it.

Can you revert this one? Otherwise, this looks good to me!

@fubhy
Copy link
Contributor Author

fubhy commented Feb 23, 2023

Ah right. Good catch, thanks! Will revert tha tone in a moment.

Copy link
Member

@timostamm timostamm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just ran this in a project using NodeNext module resolution - works like a charm.

LGTM!

@timostamm timostamm merged commit 57b4e01 into connectrpc:main Feb 23, 2023
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.

2 participants