Skip to content

Commit 7a5512c

Browse files
committed
Merge pull request #466 from sparecycles/fix/checker-declaration
fix --declaration typechecking (complex case)
2 parents 6287efc + d43f28d commit 7a5512c

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ module ts {
780780
// But it cant, hence the accessible is going to be undefined, but that doesnt mean m.c is accessible
781781
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
782782
meaningToLook = getQualifiedLeftMeaning(meaning);
783-
symbol = symbol.parent;
783+
symbol = getParentOfSymbol(symbol);
784784
}
785785

786786
// This could be a symbol that is not exported in the external module
@@ -903,7 +903,7 @@ module ts {
903903
if (accessibleSymbolChain && !needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
904904
break;
905905
}
906-
symbol = accessibleSymbolChain ? accessibleSymbolChain[0].parent : symbol.parent;
906+
symbol = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol);
907907
meaning = getQualifiedLeftMeaning(meaning);
908908
}
909909

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//// [tests/cases/compiler/moduleSymbolMerging.ts] ////
2+
3+
//// [A.ts]
4+
5+
module A { export interface I {} }
6+
7+
//// [B.ts]
8+
///<reference path="A.ts" />
9+
module A { ; }
10+
module B {
11+
export function f(): A.I { return null; }
12+
}
13+
14+
15+
16+
//// [A.js]
17+
//// [B.js]
18+
var A;
19+
(function (A) {
20+
;
21+
})(A || (A = {}));
22+
var B;
23+
(function (B) {
24+
function f() {
25+
return null;
26+
}
27+
B.f = f;
28+
})(B || (B = {}));
29+
30+
31+
//// [A.d.ts]
32+
declare module A {
33+
interface I {
34+
}
35+
}
36+
//// [B.d.ts]
37+
/// <reference path='A.d.ts' />
38+
declare module A {
39+
}
40+
declare module B {
41+
function f(): A.I;
42+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @declaration: true
2+
3+
// @Filename: A.ts
4+
module A { export interface I {} }
5+
6+
// @Filename: B.ts
7+
///<reference path="A.ts" />
8+
module A { ; }
9+
module B {
10+
export function f(): A.I { return null; }
11+
}
12+

0 commit comments

Comments
 (0)