Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.13.0
-
None
-
Patch
Description
When a service or type definition has multiple includes that are referenced in method parameters or responses the TypeScript generator will generated code that will fail to compile with tsc. This is due to "external" types not being referenced from their import; an assumption is made that they are defined the the default ttypes for the service.
With the following input
import "Other.thrift" struct MyStruct { 1:Other.OtherType field; } service MyService { Other.OtherResponse magic(1:Other.OtherRequest arg) }
The following generated TypeScript declaration is generated with 0.13.0 which will fail to compile with an invocation of "tsc *.d.ts"
// foo_types.d.ts import other_types = require("./other"); declare class MyStruct { public field: OtherType; // !!! Compile failure, unknown type OtherType } // foo_service.d.ts import other_types = require("./other"); class MyService { public magic(request: OtherRequest) : Promise<OtherResponse> // !!! Compile failure, unknown type OtherRequest, OtherResponse }
The expected output should be:
// foo_types.d.ts import other_types = require("./other"); declare class MyStruct { public field: other_types.OtherType; } // foo_service.d.ts import other_types = require("./other"); class MyService { public magic(request: other_types.OtherRequest) : Promise<other_types.OtherResponse> }
I have a fix for this with the following PR https://github.com/apache/thrift/pull/1820
Attachments
Issue Links
- links to