thrift-typescript icon indicating copy to clipboard operation
thrift-typescript copied to clipboard

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

Open treecy opened this issue 5 years ago • 6 comments

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?

treecy avatar Mar 14 '19 09:03 treecy

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.

kevin-greene-ck avatar Mar 14 '19 18:03 kevin-greene-ck

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

treecy avatar Mar 15 '19 00:03 treecy

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.

hayes avatar Apr 20 '19 01:04 hayes

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 :)

angelomelonas avatar May 17 '19 07:05 angelomelonas

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?

Aurora12 avatar Jul 30 '19 14:07 Aurora12

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

shynome avatar Oct 02 '19 09:10 shynome