Skip to content

Commit a8c2f82

Browse files
committed
Temporary fix for import case in getTypeOfNode
1 parent a08aa14 commit a8c2f82

File tree

336 files changed

+3116
-3109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

336 files changed

+3116
-3109
lines changed

src/compiler/checker.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6773,19 +6773,19 @@ module ts {
67736773
(<QualifiedName>node.parent).right === node;
67746774
}
67756775

6776-
function getSymbolOfIdentifier(identifier: Identifier) {
6777-
if (isDeclarationOrFunctionExpressionOrCatchVariableName(identifier)) {
6778-
return getSymbolOfNode(identifier.parent);
6776+
function getSymbolOfEntityName(entityName: EntityName): Symbol {
6777+
if (isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) {
6778+
return getSymbolOfNode(entityName.parent);
67796779
}
67806780

6781-
if (identifier.parent.kind === SyntaxKind.ExportAssignment) {
6782-
return resolveEntityName(/*location*/ identifier.parent.parent, identifier,
6781+
if (entityName.parent.kind === SyntaxKind.ExportAssignment) {
6782+
return resolveEntityName(/*location*/ entityName.parent.parent, entityName,
67836783
/*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Import);
67846784
}
67856785

6786-
var entityName: Node = identifier;
6787-
while (isRightSideOfQualifiedNameOrPropertyAccess(entityName))
6786+
if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
67886787
entityName = entityName.parent;
6788+
}
67896789

67906790
if (isExpression(entityName)) {
67916791
if (entityName.kind === SyntaxKind.Identifier) {
@@ -6813,12 +6813,17 @@ module ts {
68136813
meaning |= SymbolFlags.Import;
68146814
return resolveEntityName(entityName, entityName, meaning);
68156815
}
6816+
6817+
// Do we want to return undefined here?
6818+
return undefined;
68166819
}
68176820

68186821
function getSymbolInfo(node: Node) {
68196822
switch (node.kind) {
68206823
case SyntaxKind.Identifier:
6821-
return getSymbolOfIdentifier(<Identifier>node);
6824+
case SyntaxKind.PropertyAccess:
6825+
case SyntaxKind.QualifiedName:
6826+
return getSymbolOfEntityName(<Identifier>node);
68226827

68236828
case SyntaxKind.ThisKeyword:
68246829
case SyntaxKind.SuperKeyword:
@@ -6894,10 +6899,12 @@ module ts {
68946899
}
68956900
else {
68966901
// It is an import statement
6897-
while (node.kind !== SyntaxKind.ImportDeclaration) {
6902+
if (isRightSideOfQualifiedNameOrPropertyAccess(node)) {
68986903
node = node.parent;
68996904
}
6900-
symbol = getSymbolOfNode(node);
6905+
// We include all declaration spaces for aliases. This is likely too inclusive, as the rules
6906+
// for resolving aliases are quite particular. Ideally this should reuse the logic in resolveAlias.
6907+
symbol = resolveEntityName(node, node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Import);
69016908
}
69026909
var declaredType = getDeclaredTypeOfSymbol(symbol);
69036910
return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol);

tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module A {
5050
>fromorigin2d : (p: Point) => Line<Point>
5151
>p : Point
5252
>Point : Point
53-
>Line : Line
53+
>Line : Line<TPoint>
5454
>Point : Point
5555

5656
return null;

tests/baselines/reference/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module A {
1111

1212
export var beez: Array<B>;
1313
>beez : B[]
14-
>Array : Array
14+
>Array : T[]
1515
>B : B
1616

1717
export var beez2 = new Array<B>();

tests/baselines/reference/acceptableAlias1.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ module M {
1212

1313
import r = M.X;
1414
>r : r
15-
>M : M
15+
>M : typeof M
1616
>X : X
1717

tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class C<T extends IHasVisualizationModel> {
2424
}
2525
class D extends C<IHasVisualizationModel> {
2626
>D : D
27-
>C : C
27+
>C : C<T>
2828
>IHasVisualizationModel : IHasVisualizationModel
2929

3030
x = moduleA;

tests/baselines/reference/amdImportNotAsPrimaryExpression.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import foo = require("./foo_0");
55
// None of the below should cause a runtime dependency on foo_0
66
import f = foo.M1;
77
>f : f
8-
>foo : foo
8+
>foo : typeof "tests/cases/conformance/externalModules/foo_0"
99
>M1 : M1
1010

1111
var i: f.I2;

tests/baselines/reference/anyAssignabilityInInheritance.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ class A2<T> { foo: T; }
167167
declare function foo11(x: A2<string>): A2<string>;
168168
>foo11 : { (x: A2<string>): A2<string>; (x: any): any; }
169169
>x : A2<string>
170-
>A2 : A2
171-
>A2 : A2
170+
>A2 : A2<T>
171+
>A2 : A2<T>
172172

173173
declare function foo11(x: any): any;
174174
>foo11 : { (x: A2<string>): A2<string>; (x: any): any; }

tests/baselines/reference/arrayLiterals.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var classTypeArray = [C, C, C];
7878

7979
var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
8080
>classTypeArray : typeof C[]
81-
>Array : Array
81+
>Array : T[]
8282
>C : typeof C
8383

8484
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
@@ -111,7 +111,7 @@ var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
111111

112112
var context2: Array<{}>; // Should be OK
113113
>context2 : {}[]
114-
>Array : Array
114+
>Array : T[]
115115

116116
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
117117
class Base { private p; }

tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class List<T> {
99

1010
next: List<List<T>>;
1111
>next : List<List<T>>
12-
>List : List
13-
>List : List
12+
>List : List<T>
13+
>List : List<T>
1414
>T : T
1515
}
1616

1717
class DerivedList<U> extends List<U> {
1818
>DerivedList : DerivedList<U>
1919
>U : U
20-
>List : List
20+
>List : List<T>
2121
>U : U
2222

2323
foo: U;
@@ -37,22 +37,22 @@ class MyList<T> {
3737

3838
next: MyList<MyList<T>>;
3939
>next : MyList<MyList<T>>
40-
>MyList : MyList
41-
>MyList : MyList
40+
>MyList : MyList<T>
41+
>MyList : MyList<T>
4242
>T : T
4343
}
4444

4545
var list: List<number>;
4646
>list : List<number>
47-
>List : List
47+
>List : List<T>
4848

4949
var list2: List<string>;
5050
>list2 : List<string>
51-
>List : List
51+
>List : List<T>
5252

5353
var myList: MyList<number>;
5454
>myList : MyList<number>
55-
>MyList : MyList
55+
>MyList : MyList<T>
5656

5757
var xs = [list, myList]; // {}[]
5858
>xs : List<number>[]
@@ -73,7 +73,7 @@ var zs = [list, null]; // List<number>[]
7373

7474
var myDerivedList: DerivedList<number>;
7575
>myDerivedList : DerivedList<number>
76-
>DerivedList : DerivedList
76+
>DerivedList : DerivedList<U>
7777

7878
var as = [list, myDerivedList]; // List<number>[]
7979
>as : List<number>[]

tests/baselines/reference/arrayTypeInSignatureOfInterfaceAndClass.types

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ declare module WinJS {
1212
>success : (value: T) => Promise<U>
1313
>value : T
1414
>T : T
15-
>Promise : Promise
15+
>Promise : Promise<T>
1616
>U : U
1717
>error : (error: any) => Promise<U>
1818
>error : any
19-
>Promise : Promise
19+
>Promise : Promise<T>
2020
>U : U
2121
>progress : (progress: any) => void
2222
>progress : any
23-
>Promise : Promise
23+
>Promise : Promise<T>
2424
>U : U
2525
}
2626
}
@@ -66,14 +66,14 @@ declare module Data {
6666
>indices : number[]
6767
>options : any
6868
>WinJS : WinJS
69-
>Promise : Promise
70-
>IListItem : IListItem
69+
>Promise : Promise<T>
70+
>IListItem : IListItem<T>
7171
>T : T
7272
}
7373
export class VirtualList<T> implements IVirtualList<T> {
7474
>VirtualList : VirtualList<T>
7575
>T : T
76-
>IVirtualList : IVirtualList
76+
>IVirtualList : IVirtualList<T>
7777
>T : T
7878

7979
//removeIndices: WinJS.Promise<IListItem<T>[]>;
@@ -82,8 +82,8 @@ declare module Data {
8282
>indices : number[]
8383
>options : any
8484
>WinJS : WinJS
85-
>Promise : Promise
86-
>IListItem : IListItem
85+
>Promise : Promise<T>
86+
>IListItem : IListItem<T>
8787
>T : T
8888
}
8989
}

0 commit comments

Comments
 (0)