Merge pull request #6770 from Microsoft/dottedNamesInSystem
properly handle dotted namespace names in System modules
This commit is contained in:
commit
e168e945e5
5 changed files with 90 additions and 2 deletions
|
@ -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 {
|
||||
|
|
35
tests/baselines/reference/dottedNamesInSystem.js
Normal file
35
tests/baselines/reference/dottedNamesInSystem.js
Normal 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);
|
||||
}
|
||||
}
|
||||
});
|
22
tests/baselines/reference/dottedNamesInSystem.symbols
Normal file
22
tests/baselines/reference/dottedNamesInSystem.symbols
Normal 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))
|
||||
}
|
23
tests/baselines/reference/dottedNamesInSystem.types
Normal file
23
tests/baselines/reference/dottedNamesInSystem.types
Normal 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
|
||||
}
|
8
tests/cases/compiler/dottedNamesInSystem.ts
Normal file
8
tests/cases/compiler/dottedNamesInSystem.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
// @module: system
|
||||
export namespace A.B.C {
|
||||
export function foo() {}
|
||||
}
|
||||
|
||||
export function bar() {
|
||||
return A.B.C.foo();
|
||||
}
|
Loading…
Reference in a new issue