diff --git a/tools/dtsgen/declarator.ts b/tools/dtsgen/declarator.ts index f29e7f53..eb96f2a4 100644 --- a/tools/dtsgen/declarator.ts +++ b/tools/dtsgen/declarator.ts @@ -1,6 +1,8 @@ import * as ts from "typescript"; import {SyntaxKind} from "typescript"; +type TSExpression = ts.Type | ts.Node; + interface Array { last?(): T; } @@ -100,9 +102,9 @@ class StackParameters implements StackParameter { } -const generators: {[key: number]:((settings: _Settings, stack: StackParameters, node: ts.Node) => ts.Node | undefined) | undefined} = {}; +const generators: {[key: number]:((settings: _Settings, stack: StackParameters, node: ts.Node | ts.Type) => ts.Node | ts.Type | undefined) | undefined} = {}; -function _generate(settings: _Settings, stack: StackParameters, layer: ts.Node[], node: ts.Node) { +function _generate(settings: _Settings, stack: StackParameters, layer: TSExpression[], node: ts.Node) { //console.log(SyntaxKind[node.kind]); if(generators[node.kind]) { const result = generators[node.kind](settings, stack, node); @@ -322,7 +324,6 @@ generators[SyntaxKind.ClassDeclaration] = (settings, stack, node: ts.ClassDeclar }; generators[SyntaxKind.PropertySignature] = (settings, stack, node: ts.PropertySignature) => { - console.log(SyntaxKind[node.type.kind]); let type: ts.TypeNode = node.type; switch (node.type.kind) { case SyntaxKind.LiteralType: @@ -383,4 +384,11 @@ generators[SyntaxKind.EnumDeclaration] = (settings, stack, node: ts.EnumDeclarat for(const member of node.members) members.push(generators[SyntaxKind.EnumMember](settings, stack, member)); return ts.createEnumDeclaration(undefined, append_export(append_declare(node.modifiers, !stack.flag_declare), stack.flag_namespace), node.name, members); -}; \ No newline at end of file +}; + + +generators[SyntaxKind.TypeParameter] = (settings, stack, node: ts.TypeParameter) => undefined; +generators[SyntaxKind.HeritageClause] = (settings, stack, node: ts.HeritageClause) => undefined; +generators[SyntaxKind.IfStatement] = (settings, stack, node: ts.IfStatement) => undefined; +generators[SyntaxKind.ExpressionStatement] = (settings, stack, node: ts.ExpressionStatement) => undefined; +generators[SyntaxKind.SemicolonClassElement] = (settings, stack, node: ts.ExpressionStatement) => undefined; \ No newline at end of file diff --git a/tools/dtsgen/out.d.ts b/tools/dtsgen/out.d.ts index 152bd336..d2410873 100644 --- a/tools/dtsgen/out.d.ts +++ b/tools/dtsgen/out.d.ts @@ -1,13 +1,6 @@ -/* 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 */ +declare class TestClass extends Promise { } +declare const lambda_function; +declare const lambda_function2; diff --git a/tools/dtsgen/test/test_04.ts b/tools/dtsgen/test/test_04.ts new file mode 100644 index 00000000..1263a5e6 --- /dev/null +++ b/tools/dtsgen/test/test_04.ts @@ -0,0 +1,4 @@ +class TestClass extends Promise { } + +const lambda_function = (str) => {}; +const lambda_function2 = (str: string) => {}; \ No newline at end of file