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

Fix type declaration emitting when using NodeNext module resolution #398

Merged
merged 4 commits into from
Feb 24, 2023
Merged

Conversation

fubhy
Copy link
Contributor

@fubhy fubhy commented Feb 23, 2023

Removes --noEmit when testing compilation with the various tsc versions and configures declarations and declarationMap to be emitted.

Adds a ProtoRuntime typehint to the runtime property on generated messages.

Fixes #396

@fubhy fubhy changed the title Demonstrate failing tests when emitting type declaration files WIP: Fix type declaration emitting when using NodeNext module resolution Feb 23, 2023
@fubhy fubhy changed the title WIP: Fix type declaration emitting when using NodeNext module resolution Fix type declaration emitting when using NodeNext module resolution Feb 23, 2023
packages/protobuf/src/index.ts Outdated Show resolved Hide resolved
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.

Can confirm that d99b803 fails the tests 👍

Seems that declarationMap is not necessary to trigger, but I think it's a good call to leave it in.

Can you make the simplification with typeof protoN and re-using the dist directory and add explanatory comments suggested below?

Makefile Outdated Show resolved Hide resolved
.eslintrc.cjs Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
.prettierignore Outdated Show resolved Hide resolved
packages/protoc-gen-es/src/typescript.ts Outdated Show resolved Hide resolved
packages/protobuf/src/codegen-info.ts Outdated Show resolved Hide resolved
packages/protobuf/src/index.ts Outdated Show resolved Hide resolved
@fubhy
Copy link
Contributor Author

fubhy commented Feb 24, 2023

@timostamm Thanks for the review. I force-pushed two commits on top of the test-failure demonstration commit to make it easier to re-review for you (considering all the noise with the generated files).

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.

Thank you for this fix!

@@ -10,5 +10,5 @@ server would usually do.

| code generator | bundle size | minified | compressed |
|---------------------|------------------------:|-----------------------:|-------------------:|
| protobuf-es | 86,785 b | 36,950 b | 9,642 b |
| protobuf-es | 86,785 b | 36,950 b | 9,654 b |
Copy link
Member

Choose a reason for hiding this comment

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

Just for posterity: This is the usual flake we get from using Node.js zlib on different platforms. I don't see any bundle size change.

@timostamm timostamm merged commit c3d8e3d into bufbuild:main Feb 24, 2023
This was referenced Feb 28, 2023
smaye81 added a commit that referenced this pull request Mar 2, 2023
This release includes the following:

## Enhancements
* Support size-delimited messages by @timostamm in #387.

## Bug Fixes
*  Upgrade to Protobuf v22.0 by @smaye81 in #394.
* Fix type declaration emitting when using NodeNext module resolution by
@fubhy in #398.
*  Strip rewrite_imports parameter by @smaye81 in #386.

## New Contributors
* @s-hakase made their first contribution in #367.
* @balzdur made their first contribution in #368.
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.

Type resolution for generated code struggles when using NodeNext
2 participants