Skip to content

Commit a1e65a6

Browse files
glentakahashiryanmcnamara
authored andcommitted
Upgrade the typescript-generator backend (#54)
* Upgrade the typescript-generator backend * Fixed union types * Fix tests * Improve comment
1 parent 1a61e8f commit a1e65a6

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ guavaVersion=18.0
66
feignVersion=8.10.0
77
jacksonVersion=2.6.1
88
jaxRsVersion=2.0.1
9-
typescriptGeneratorVersion=1.7.190
9+
typescriptGeneratorVersion=1.25.322
1010
commonsIOVersion=2.4
1111
findbugsAnnotationsVersion=3.0.0
1212

typescript-service-generator-core/src/main/java/com/palantir/code/ts/generator/TypescriptServiceGeneratorConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ public Settings getSettings() {
213213
settings.addTypeNamePrefix = generatedInterfacePrefix();
214214
settings.sortDeclarations = true;
215215
settings.noFileComment = true;
216+
// behave like 0.9.0; also fixes when subtypes use generics
217+
settings.disableTaggedUnions = true;
216218
settings.jsonLibrary = JsonLibrary.jackson2;
217219
settings.optionalAnnotations = optionalAnnotations();
218220
settings.outputKind = TypeScriptOutputKind.global;

typescript-service-generator-core/src/test/java/com/palantir/code/ts/generator/ServiceEmitterTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void testComplexServiceClassEmitTypes() {
6868
"\n" +
6969
" export interface MyObject {\n" +
7070
" y: MyObject;\n" +
71-
" }\n" +
71+
" }\n\n\n // Added by 'EnumConstantsExtension' extension\n" +
7272
"";
7373
assertEquals(expectedOutput, new String(stream.toByteArray()));
7474
}
@@ -232,7 +232,7 @@ public void testAdditionalClassesToOutput() {
232232
String expectedOutput = "\n" +
233233
" export interface MyObject {\n" +
234234
" y: MyObject;\n" +
235-
" }\n";
235+
" }\n\n\n // Added by 'EnumConstantsExtension' extension\n";
236236
assertEquals(expectedOutput, new String(stream.toByteArray()));
237237
}
238238

@@ -244,7 +244,7 @@ public void testEnumClass() {
244244
writer.close();
245245
String expectedOutput = "\n" +
246246
" export type MyEnum = \"VALUE1\" | \"VALUE2\";\n" +
247-
"\n" +
247+
"\n\n // Added by 'EnumConstantsExtension' extension\n\n" +
248248
" export const MyEnum = {\n" +
249249
" VALUE1: <MyEnum>\"VALUE1\",\n" +
250250
" VALUE2: <MyEnum>\"VALUE2\",\n" +

typescript-service-generator-core/src/test/resources/eteTestData/complexServiceTestOutput/testComplexServiceClass.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ module ModuleName.TestComplexServiceClass {
1818
y: IMyObject;
1919
}
2020

21+
22+
// Added by 'EnumConstantsExtension' extension
23+
2124
export interface ITestComplexServiceClass {
2225
allOptionsPost(a: string, dataObject: IDataObject, b?: number): FooReturn<IGenericObject<IMyObject>>;
2326
queryGetter(x?: boolean): FooReturn<IMyObject>;

typescript-service-generator-core/src/test/resources/eteTestData/simpleServiceTestOutput/simpleService1.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// Generated
33
import { HttpEndpointOptions, HttpApiBridge } from "./httpApiBridge";
44

5+
6+
// Added by 'EnumConstantsExtension' extension
7+
58
export interface SimpleService1 {
69
method1(): FooReturn<string>;
710
}

0 commit comments

Comments
 (0)