fixed type leaks in namespaces

canary
WolverinDEV 2019-08-30 19:16:47 +02:00
parent b164685ffe
commit 6df7b216ec
2 changed files with 19 additions and 1 deletions

View File

@ -119,7 +119,7 @@ class StackParameters implements StackParameter {
const generators: {[key: number]:((settings: _Settings, stack: StackParameters, node: ts.Node) => ts.Node | undefined) | undefined} = {};
function _generate(settings: _Settings, stack: StackParameters, layer: ts.Node[], node: ts.Node) {
console.log(SyntaxKind[node.kind]);
//console.log(SyntaxKind[node.kind]);
if(generators[node.kind]) {
const result = generators[node.kind](settings, stack, node);
if(result)
@ -381,6 +381,8 @@ generators[SyntaxKind.VariableStatement] = (settings, stack, node: ts.VariableSt
};
generators[SyntaxKind.TypeAliasDeclaration] = (settings, stack, node: ts.TypeAliasDeclaration) => {
if(stack.flag_namespace && !has_modifier(node.modifiers, SyntaxKind.ExportKeyword)) return;
let type = node.type;
if(type.kind == SyntaxKind.UnionType) {
const union_members = [];
@ -406,3 +408,12 @@ generators[SyntaxKind.EnumDeclaration] = (settings, stack, node: ts.EnumDeclarat
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);
};
/* every variable in a block has no global scope! */
generators[SyntaxKind.Block] = (settings, stack, node: ts.EnumMember) => {
return undefined;
};
generators[SyntaxKind.IfStatement] = (settings, stack, node: ts.EnumMember) => {
return undefined;
};

View File

@ -0,0 +1,7 @@
namespace C {
type B = string;
}
namespace C {
type B = string;
export function test(arg: string) {}
}