-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
TS2742: The inferred type of 'X' cannot be named without a reference #60624
Comments
What's the emitted declaration for |
@Andarist its enum generated from proto file ...
enum Price {
PRICE_UNSPECIFIED = 0;
PRICE_PAID = 1;
PRICE_FREE = 2;
}
... |
This error is raised on: export const Price = /*@__PURE__*/ proto3.makeEnum( when attempting to generate a // generated.d.ts
export declare const Price: ??? |
in d.ts file generated by @bufbuild/protoc-gen-es version: v1
plugins:
- plugin: es
out: src/protos
opt: target=js+dts
- plugin: connect-es
out: src/protos
opt:
- target=js+dts I see next lines export declare enum Price {
/**
* @generated from enum value: PRICE_UNSPECIFIED = 0;
*/
UNSPECIFIED = 0,
/**
* @generated from enum value: PRICE_PAID = 1;
*/
PAID = 1,
/**
* @generated from enum value: PRICE_FREE = 2;
*/
FREE = 2,
} when I build project with tsc (typescript 5.6.3) then in dist folder d.ts proto file looks like: export const Price: import("../../../../node_modules/@bufbuild/protobuf/dist/esm/private/enum.js").EnumObject; I don't know what else you want from me. |
I was interested exactly in this information: export const Price: import("../../../../node_modules/@bufbuild/protobuf/dist/esm/private/enum.js").EnumObject; Thank you for providing it. To be fair, this emitted declaration wasn't really that portable in the first place. I don't know what changed in which PR but an emitted type like this is sus. To address this issue I'd recommend doing this:
|
See #58176 (comment) and #42873 (comment) |
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
π Search Terms
ts2742, inferred type, bufbuild, protobuf, es, proto3
π Version & Regression Information
β― Playground Link
No response
π» Code
π Actual behavior
When using proto files with enums generated with @bufbuild/protoc-gen-es we've got this error on project build with typescript 5.7.x.
π Expected behavior
Project builds successfull with TypeScript <= 5.6.3.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: