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

import = is not supported by @babel/plugin-transform-typescript #150

Open
treecy opened this issue Mar 14, 2019 · 6 comments
Open

import = is not supported by @babel/plugin-transform-typescript #150

treecy opened this issue Mar 14, 2019 · 6 comments

Comments

@treecy
Copy link

treecy commented Mar 14, 2019

For Int64 the generated code is:

import Int64 = require("node-int64");

But this syntax is not supported by @babel/plugin-transform-typescript, and I think

import Int64 from "node-int64"

should work the same.

I wonder why choosed to use import = statement?

@kevin-greene-ck
Copy link
Contributor

If I remember correctly it was because of the way @types/node-int64 were defined. They wouldn't import properly with the standard form (import Int64 from 'node-int64') because they don't define a default export. I'll double check and we'll explore a fix.

@treecy
Copy link
Author

treecy commented Mar 15, 2019

@kevin-greene-ck
Oh, I see! Thank you !

@hayes
Copy link
Contributor

hayes commented Apr 20, 2019

I've opened #155 to update the thrift-server output to imit import = statements. Doing this for the apache output might be a little harder, but I have not looked at it closely.

@angelomelonas
Copy link

I am currently using the Apache Thrift output and also get the Import assignment cannot be used when targeting ECMAScript modules. error on the import Int64 = require("node-int64"); line in one of the generated files using an i64 variable.

I am also patiently waiting for an update on this one :)

@Aurora12
Copy link

Aurora12 commented Jul 30, 2019

I've just run into this issue. Actually, I'm trying to make use of thrift-typescript on the browser front end. While I can replace the require("node-int64") in all generated files with a nasty bash find + sed command, I'm still not able to compile the result without Node, so it wouldn't be available in the browser environment. Am I doing something wrong entirely?

@shynome
Copy link

shynome commented Oct 2, 2019

I also have this problem.

I change import Int64 = require("node-int64"); to import Int64 from "node-int64";, that make my next.js api work

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

6 participants