Merge pull request #6770 from Microsoft/dottedNamesInSystem

properly handle dotted namespace names in System modules
This commit is contained in:
Vladimir Matveev 2016-02-01 10:01:05 -08:00
commit e168e945e5
5 changed files with 90 additions and 2 deletions

View file

@ -2583,12 +2583,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
return false;
}
let current: Node = node;
let current = getRootDeclaration(node).parent;
while (current) {
if (current.kind === SyntaxKind.SourceFile) {
return !isExported || ((getCombinedNodeFlags(node) & NodeFlags.Export) !== 0);
}
else if (isFunctionLike(current) || current.kind === SyntaxKind.ModuleBlock) {
else if (isDeclaration(current)) {
return false;
}
else {

View file

@ -0,0 +1,35 @@
//// [dottedNamesInSystem.ts]
export namespace A.B.C {
export function foo() {}
}
export function bar() {
return A.B.C.foo();
}
//// [dottedNamesInSystem.js]
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var A;
function bar() {
return A.B.C.foo();
}
exports_1("bar", bar);
return {
setters:[],
execute: function() {
(function (A) {
var B;
(function (B) {
var C;
(function (C) {
function foo() { }
C.foo = foo;
})(C = B.C || (B.C = {}));
})(B = A.B || (A.B = {}));
})(A = A || (A = {}));
exports_1("A", A);
}
}
});

View file

@ -0,0 +1,22 @@
=== tests/cases/compiler/dottedNamesInSystem.ts ===
export namespace A.B.C {
>A : Symbol(A, Decl(dottedNamesInSystem.ts, 0, 0))
>B : Symbol(B, Decl(dottedNamesInSystem.ts, 0, 19))
>C : Symbol(C, Decl(dottedNamesInSystem.ts, 0, 21))
export function foo() {}
>foo : Symbol(foo, Decl(dottedNamesInSystem.ts, 0, 24))
}
export function bar() {
>bar : Symbol(bar, Decl(dottedNamesInSystem.ts, 2, 1))
return A.B.C.foo();
>A.B.C.foo : Symbol(A.B.C.foo, Decl(dottedNamesInSystem.ts, 0, 24))
>A.B.C : Symbol(A.B.C, Decl(dottedNamesInSystem.ts, 0, 21))
>A.B : Symbol(A.B, Decl(dottedNamesInSystem.ts, 0, 19))
>A : Symbol(A, Decl(dottedNamesInSystem.ts, 0, 0))
>B : Symbol(A.B, Decl(dottedNamesInSystem.ts, 0, 19))
>C : Symbol(A.B.C, Decl(dottedNamesInSystem.ts, 0, 21))
>foo : Symbol(A.B.C.foo, Decl(dottedNamesInSystem.ts, 0, 24))
}

View file

@ -0,0 +1,23 @@
=== tests/cases/compiler/dottedNamesInSystem.ts ===
export namespace A.B.C {
>A : typeof A
>B : typeof B
>C : typeof C
export function foo() {}
>foo : () => void
}
export function bar() {
>bar : () => void
return A.B.C.foo();
>A.B.C.foo() : void
>A.B.C.foo : () => void
>A.B.C : typeof A.B.C
>A.B : typeof A.B
>A : typeof A
>B : typeof A.B
>C : typeof A.B.C
>foo : () => void
}

View file

@ -0,0 +1,8 @@
// @module: system
export namespace A.B.C {
export function foo() {}
}
export function bar() {
return A.B.C.foo();
}