diff --git a/tools/dtsgen/declarator.ts b/tools/dtsgen/declarator.ts index f29e7f53..4c2bc21a 100644 --- a/tools/dtsgen/declarator.ts +++ b/tools/dtsgen/declarator.ts @@ -371,7 +371,24 @@ generators[SyntaxKind.VariableStatement] = (settings, stack, node: ts.VariableSt }; generators[SyntaxKind.TypeAliasDeclaration] = (settings, stack, node: ts.TypeAliasDeclaration) => { - return node; + let type = node.type; + if(type.kind == SyntaxKind.UnionType) { + const union_members = []; + const union = node.type; + + for(const element of union.types as any as any[]) { + if(element.kind === SyntaxKind.LiteralType && element.literal && element.literal.text) { + union_members.push(ts.createStringLiteral(element.literal.text)); + } + else + union_members.push(element); + console.log(SyntaxKind[element.kind]); + } + + type = ts.createUnionTypeNode(union_members); + } + + return ts.createTypeAliasDeclaration(node.decorators, node.modifiers, node.name, node.typeParameters, type); }; generators[SyntaxKind.EnumMember] = (settings, stack, node: ts.EnumMember) => { diff --git a/tools/dtsgen/out.d.ts b/tools/dtsgen/out.d.ts index 152bd336..a83ad91e 100644 --- a/tools/dtsgen/out.d.ts +++ b/tools/dtsgen/out.d.ts @@ -1,13 +1,5 @@ -/* File: /home/wolverindev/TeaSpeak/TeaSpeak/Web-Client/tools/dtsgen/test/test_03.ts */ -declare enum YY { - H, - B -} -declare interface X { - type: any; - c: YY.B; -} -declare class X { - static x(); -} +/* File: /home/wolverindev/TeaSpeak/TeaSpeak/Web-Client/tools/dtsgen/test/test_04.ts */ +type T = "a" | "b" | "c"; +declare function _t(parm: T); +declare function __t(); diff --git a/tools/dtsgen/test/test_04.ts b/tools/dtsgen/test/test_04.ts new file mode 100644 index 00000000..bad78697 --- /dev/null +++ b/tools/dtsgen/test/test_04.ts @@ -0,0 +1,5 @@ +type T = "a" | "b" | "c"; + +function _t(parm: T) {} + +function __t() {} \ No newline at end of file