Added a new test case and fixed some missing generators

canary
WolverinDEV 2019-02-25 16:45:03 +01:00
parent 8cf967fd80
commit 9818385a29
3 changed files with 20 additions and 15 deletions

View File

@ -1,6 +1,8 @@
import * as ts from "typescript";
import {SyntaxKind} from "typescript";
type TSExpression = ts.Type | ts.Node;
interface Array<T> {
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);
};
};
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;

15
tools/dtsgen/out.d.ts vendored
View File

@ -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<T> extends Promise<T> {
}
declare const lambda_function;
declare const lambda_function2;

View File

@ -0,0 +1,4 @@
class TestClass<T> extends Promise<T> { }
const lambda_function = (str) => {};
const lambda_function2 = (str: string) => {};