You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TS2742: The inferred type of 'X' cannot be named without a reference #60624
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.
error TS2742: The inferred type of 'Price' cannot be named without a reference to '../../../../node_modules/@bufbuild/protobuf/dist/esm/private/enum.js'. This is likely not portable. A type annotation is necessary.
58 export const Price = /*@__PURE__*/ proto3.makeEnum(
~~~~~
🙂 Expected behavior
Project builds successfull with TypeScript <= 5.6.3.
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:
adding a dependency on @bufbuild/protobuf. Presumably this is a dependency of your dependency (a so-called transitive dependency)
making sure that EnumObject can be imported from @bufbuild/protobuf
try to annotate const Price: ? manually. If you can't do it manually then the compiler won't be able to do so either
Activity
Andarist commentedon Nov 27, 2024
What's the emitted declaration for
Pricethere?Aliaksandr-K-JazzTeam commentedon Nov 27, 2024
Mateusz Burzyński (@Andarist) its enum generated from proto file
Andarist commentedon Nov 27, 2024
This error is raised on:
when attempting to generate a
.d.tsfor the containing file. I wonder what TS put before at this position:Aliaksandr-K-JazzTeam commentedon Nov 27, 2024
in d.ts file generated by @bufbuild/protoc-gen-es
buf.gen.yaml
I see next lines
when I build project with tsc (typescript 5.6.3) then in dist folder d.ts proto file looks like:
I don't know what else you want from me.
Andarist commentedon Nov 27, 2024
I was interested exactly in this information:
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:
@bufbuild/protobuf. Presumably this is a dependency of your dependency (a so-called transitive dependency)EnumObjectcan be imported from@bufbuild/protobufconst Price: ?manually. If you can't do it manually then the compiler won't be able to do so eitherRyanCavanaugh commentedon Nov 27, 2024
See #58176 (comment) and #42873 (comment)
typescript-bot commentedon Nov 30, 2024
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes.