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

bug: incorrect long import syntax when uint64 used #887

Closed
TeemuKoivisto opened this issue Jul 18, 2023 · 2 comments
Closed

bug: incorrect long import syntax when uint64 used #887

TeemuKoivisto opened this issue Jul 18, 2023 · 2 comments

Comments

@TeemuKoivisto
Copy link

TeemuKoivisto commented Jul 18, 2023

Hey, so I noticed that using uint64s are bit harder with protobuf. Seems you need an additional library to handle them with JS. While I'm sure the long library works fine, it seems there's something wrong with the import syntax.

As of now, when I compile my proto files it produces a .ts file with import Long = require("long"); statement that my tsc fails to compile throwing:

error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.

4 import Long = require("long");

In the PR which adds this #882 it says it should use import Long from "long" when "esModuleInterop": true which should work. But even though I have it enabled, it uses the incorrect import syntax.

I can add a reproduction if necessary. I am using "ts-proto": "1.155.1" and "typescript": "4.9.4"

@davidzeng0
Copy link
Contributor

Try passing --ts_proto_opt=esModuleInterop=true to protoc

@TeemuKoivisto
Copy link
Author

Try passing --ts_proto_opt=esModuleInterop=true to protoc

Nice, thanks! Works 👍

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

No branches or pull requests

2 participants