Skip to content

Commit

Permalink
fixed & tested
Browse files Browse the repository at this point in the history
  • Loading branch information
Crusader4Christ committed Sep 11, 2020
1 parent 2005b68 commit 5f15938
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
19 changes: 7 additions & 12 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ export class Compiler {
case ts.SyntaxKind.ImportDeclaration:
return this._compileImportDeclaration(node as ts.ImportDeclaration);
case ts.SyntaxKind.ModuleDeclaration:
const body: ts.ModuleBody = node["body"];
if ("statements" in body) {
return body.statements.map(this.compileNode, this).filter(s => s).join("\n\n");
}
//return this._compileNamespaceDeclaration(node as ts.NamespaceDeclaration);
return this._compileNamespaceDeclaration(node as ts.NamespaceDeclaration);
case ts.SyntaxKind.SourceFile: return this._compileSourceFile(node as ts.SourceFile);
case ts.SyntaxKind.AnyKeyword: return '"any"';
case ts.SyntaxKind.NumberKeyword: return '"number"';
Expand Down Expand Up @@ -198,6 +194,7 @@ export class Compiler {
let counter = 0;
const members: string[] = node.members.map(m => {
let value = getTextOfConstantValue(this.checker.getConstantValue(m));
//for some strange reason enum members inside namespaces are undefined
if (value === "undefined") {
value = counter.toString(10);
++counter;
Expand Down Expand Up @@ -236,13 +233,11 @@ export class Compiler {
private _compileParenthesizedTypeNode(node: ts.ParenthesizedTypeNode): string {
return this.compileNode(node.type);
}
// private _compileNamespaceDeclaration(node: ts.NamespaceDeclaration): string {
// if ("statements" in node.body) {
// const name = this.getName(node.name);
// const prefix = node.modifiers.map(n => n.getText()).filter(s => s).join(" ");
// return `${prefix} ${name} {\n${this._compileSourceFileStatements(node.body.statements)}\n}\n`;
// }
// }
private _compileNamespaceDeclaration(node: ts.NamespaceDeclaration): string {
if ("statements" in node.body) {
return node.body.statements.map(this.compileNode, this).filter(s => s).join("\n\n");
}
}
private _compileImportDeclaration(node: ts.ImportDeclaration): string {
if (this.options.inlineImports) {
const importedSym = this.checker.getSymbolAtLocation(node.moduleSpecifier);
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2018",
"strict": false,
"target": "es6",
"strict": true,
"noUnusedLocals": true,
"module": "commonjs",
"baseUrl": ".",
Expand Down

0 comments on commit 5f15938

Please sign in to comment.