Skip to content

Commit 828a1cd

Browse files
committed
More type baseline changes
1 parent cc20bb1 commit 828a1cd

File tree

556 files changed

+10555
-10438
lines changed

Some content is hidden

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

556 files changed

+10555
-10438
lines changed

src/compiler/checker.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ module ts {
906906
// Get qualified name
907907
if (enclosingDeclaration &&
908908
// Properties/methods/Signatures/Constructors/TypeParameters do not need qualification
909-
!(symbol.flags & SymbolFlags.PropertyOrAccessor & SymbolFlags.Signature & SymbolFlags.Constructor & SymbolFlags.Method & SymbolFlags.TypeParameter)) {
909+
!(symbol.flags & (SymbolFlags.PropertyOrAccessor | SymbolFlags.Signature | SymbolFlags.Constructor | SymbolFlags.Method | SymbolFlags.TypeParameter))) {
910910
var symbolName: string;
911911
while (symbol) {
912912
var isFirstName = !symbolName;
@@ -1036,8 +1036,10 @@ module ts {
10361036
(type.symbol.parent || // is exported function symbol
10371037
ts.forEach(type.symbol.declarations, declaration =>
10381038
declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock));
1039-
1040-
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
1039+
if (isStaticMethodSymbol) {
1040+
return false;
1041+
}
1042+
if (isNonLocalFunctionSymbol) {
10411043
// typeof is allowed only for static/non local functions
10421044
return !!(flags & TypeFormatFlags.UseTypeOfFunction) || // use typeof if format flags specify it
10431045
(typeStack && contains(typeStack, type)); // it is type of the symbol uses itself recursively
@@ -2237,11 +2239,11 @@ module ts {
22372239
}
22382240
var type = getDeclaredTypeOfSymbol(symbol);
22392241
if (!(type.flags & TypeFlags.ObjectType)) {
2240-
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, name);
2242+
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name);
22412243
return emptyObjectType;
22422244
}
22432245
if (((<InterfaceType>type).typeParameters ? (<InterfaceType>type).typeParameters.length : 0) !== arity) {
2244-
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, name, arity);
2246+
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity);
22452247
return emptyObjectType;
22462248
}
22472249
return <ObjectType>type;
@@ -6680,6 +6682,7 @@ module ts {
66806682
case SyntaxKind.Parameter:
66816683
case SyntaxKind.Property:
66826684
case SyntaxKind.EnumMember:
6685+
case SyntaxKind.PropertyAssignment:
66836686
return (<VariableDeclaration>parent).initializer === node;
66846687
case SyntaxKind.ExpressionStatement:
66856688
case SyntaxKind.IfStatement:
@@ -6809,6 +6812,11 @@ module ts {
68096812
/*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Import);
68106813
}
68116814

6815+
if (isInRightSideOfImportOrExportAssignment(entityName)) {
6816+
// Since we already checked for ExportAssignment, this really could only be an Import
6817+
return getSymbolOfPartOfRightHandSideOfImport(entityName);
6818+
}
6819+
68126820
if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
68136821
entityName = entityName.parent;
68146822
}
@@ -6907,6 +6915,18 @@ module ts {
69076915
return getDeclaredTypeOfSymbol(symbol);
69086916
}
69096917

6918+
if (node.kind === SyntaxKind.ModuleDeclaration ||
6919+
node.kind === SyntaxKind.ImportDeclaration) {
6920+
return unknownType;
6921+
}
6922+
6923+
if (node.parent.kind === SyntaxKind.ModuleDeclaration ||
6924+
node.parent.kind === SyntaxKind.ImportDeclaration) {
6925+
if ((<Declaration>node.parent).name === node) {
6926+
return unknownType;
6927+
}
6928+
}
6929+
69106930
if (isDeclaration(node)) {
69116931
// In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration
69126932
var symbol = getSymbolOfNode(node);
@@ -6920,10 +6940,7 @@ module ts {
69206940

69216941
if (isInRightSideOfImportOrExportAssignment(node)) {
69226942
var symbol: Symbol;
6923-
symbol = node.parent.kind === SyntaxKind.ExportAssignment
6924-
? getSymbolInfo(node)
6925-
: getSymbolOfPartOfRightHandSideOfImport(node);
6926-
6943+
symbol = getSymbolInfo(node);
69276944
var declaredType = getDeclaredTypeOfSymbol(symbol);
69286945
return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol);
69296946
}

src/harness/compilerRunner.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ class CompilerBaselineRunner extends RunnerBase {
6868
var createNewInstance = false;
6969

7070
before(() => {
71+
justName = fileName.replace(/^.*[\\\/]/, ''); // strips the fileName from the path.
72+
content = Harness.IO.readFile(fileName);
73+
testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName);
74+
units = testCaseContent.testUnitData;
75+
tcSettings = testCaseContent.settings;
76+
createNewInstance = false;
77+
lastUnit = units[units.length - 1];
78+
rootDir = lastUnit.originalFilePath.indexOf('conformance') === -1 ? 'tests/cases/compiler/' : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf('/')) + '/';
7179
harnessCompiler = Harness.Compiler.getCompiler();
7280
// We need to assemble the list of input files for the compiler and other related files on the 'filesystem' (ie in a multi-file test)
7381
// If the last file in a test uses require or a triple slash reference we'll assume all other files will be brought in via references,

src/harness/typeWriter.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ class TypeWriterWalker {
7878
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterFromPosition(actualPos);
7979
var sourceText = ts.getSourceTextOfNodeFromSourceText(this.currentSourceFile.text, node);
8080
var isUnknownType = (<ts.IntrinsicType>type).intrinsicName === "unknown";
81+
if (isUnknownType) {
82+
var symbol = this.checker.getSymbolInfo(node);
83+
}
84+
else {
85+
var writeArrayAsGenericType = node.kind === ts.SyntaxKind.Identifier && (<ts.Identifier>node).text === "Array" ? ts.TypeFormatFlags.WriteArrayAsGenericType : 0;
86+
}
8187

8288
// If we got an unknown type, we temporarily want to fall back to just pretending the name
8389
// (source text) of the node is the type. This is to align with the old typeWriter to make
@@ -87,7 +93,9 @@ class TypeWriterWalker {
8793
column: lineAndCharacter.character,
8894
syntaxKind: ts.SyntaxKind[node.kind],
8995
identifierName: sourceText,
90-
type: isUnknownType ? sourceText : this.checker.typeToString(type, undefined, ts.TypeFormatFlags.UseTypeOfFunction)
96+
type: isUnknownType
97+
? this.checker.symbolToString(symbol, node.parent, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace | ts.SymbolFlags.Import)
98+
: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.UseTypeOfFunction | writeArrayAsGenericType)
9199
});
92100
}
93101

tests/baselines/reference/AmbientModuleAndAmbientFunctionWithTheSameNameAndCommonRoot.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
22
declare module Point {
3-
>Point : typeof Point
3+
>Point : Point
44

55
export var Origin: { x: number; y: number; }
66
>Origin : { x: number; y: number; }

tests/baselines/reference/AmbientModuleAndAmbientWithSameNameAndCommonRoot.types

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
22
declare module A {
3-
>A : typeof A
3+
>A : A
44

55
export module Point {
6-
>Point : typeof Point
6+
>Point : Point
77

88
export var Origin: {
99
>Origin : { x: number; y: number; }
@@ -19,7 +19,7 @@ declare module A {
1919

2020
=== tests/cases/conformance/internalModules/DeclarationMerging/class.d.ts ===
2121
declare module A {
22-
>A : typeof A
22+
>A : A
2323

2424
export class Point {
2525
>Point : Point
@@ -45,15 +45,15 @@ var p: { x: number; y: number; }
4545
var p = A.Point.Origin;
4646
>p : { x: number; y: number; }
4747
>A.Point.Origin : { x: number; y: number; }
48-
>A.Point : typeof Point
48+
>A.Point : typeof A.Point
4949
>A : typeof A
50-
>Point : typeof Point
50+
>Point : typeof A.Point
5151
>Origin : { x: number; y: number; }
5252

5353
var p = new A.Point(0, 0); // unexpected error here, bug 840000
5454
>p : { x: number; y: number; }
55-
>new A.Point(0, 0) : Point
56-
>A.Point : typeof Point
55+
>new A.Point(0, 0) : A.Point
56+
>A.Point : typeof A.Point
5757
>A : typeof A
58-
>Point : typeof Point
58+
>Point : typeof A.Point
5959

tests/baselines/reference/AmbientModuleAndNonAmbientClassWithSameNameAndCommonRoot.types

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
22
declare module A {
3-
>A : typeof A
3+
>A : A
44

55
export module Point {
6-
>Point : typeof Point
6+
>Point : Point
77

88
export var Origin: {
99
>Origin : { x: number; y: number; }
@@ -19,7 +19,7 @@ declare module A {
1919

2020
=== tests/cases/conformance/internalModules/DeclarationMerging/classPoint.ts ===
2121
module A {
22-
>A : typeof A
22+
>A : A
2323

2424
export class Point {
2525
>Point : Point
@@ -39,15 +39,15 @@ var p: { x: number; y: number; }
3939
var p = A.Point.Origin;
4040
>p : { x: number; y: number; }
4141
>A.Point.Origin : { x: number; y: number; }
42-
>A.Point : typeof Point
42+
>A.Point : typeof A.Point
4343
>A : typeof A
44-
>Point : typeof Point
44+
>Point : typeof A.Point
4545
>Origin : { x: number; y: number; }
4646

4747
var p = new A.Point(0, 0); // unexpected error here, bug 840000
4848
>p : { x: number; y: number; }
49-
>new A.Point(0, 0) : Point
50-
>A.Point : typeof Point
49+
>new A.Point(0, 0) : A.Point
50+
>A.Point : typeof A.Point
5151
>A : typeof A
52-
>Point : typeof Point
52+
>Point : typeof A.Point
5353

tests/baselines/reference/AmbientModuleAndNonAmbientFunctionWithTheSameNameAndCommonRoot.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
22
declare module Point {
3-
>Point : typeof Point
3+
>Point : Point
44

55
export var Origin: { x: number; y: number; }
66
>Origin : { x: number; y: number; }

tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.types

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ class Point {
77
>y : number
88

99
static Origin(): Point { return { x: 0, y: 0 }; }
10-
>Origin : typeof Origin
10+
>Origin : () => Point
1111
>Point : Point
1212
>{ x: 0, y: 0 } : { x: number; y: number; }
1313
>x : number
1414
>y : number
1515
}
1616

1717
module Point {
18-
>Point : typeof Point
18+
>Point : Point
1919

2020
function Origin() { return ""; }// not an error, since not exported
2121
>Origin : typeof Origin
2222
}
2323

2424

2525
module A {
26-
>A : typeof A
26+
>A : A
2727

2828
export class Point {
2929
>Point : Point
@@ -33,15 +33,15 @@ module A {
3333
>y : number
3434

3535
static Origin(): Point { return { x: 0, y: 0 }; }
36-
>Origin : typeof Origin
36+
>Origin : () => Point
3737
>Point : Point
3838
>{ x: 0, y: 0 } : { x: number; y: number; }
3939
>x : number
4040
>y : number
4141
}
4242

4343
export module Point {
44-
>Point : typeof Point
44+
>Point : Point
4545

4646
function Origin() { return ""; }// not an error since not exported
4747
>Origin : typeof Origin

tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class Point {
1515
}
1616

1717
module Point {
18-
>Point : typeof Point
18+
>Point : Point
1919

2020
var Origin = ""; // not an error, since not exported
2121
>Origin : string
2222
}
2323

2424

2525
module A {
26-
>A : typeof A
26+
>A : A
2727

2828
export class Point {
2929
>Point : Point
@@ -41,7 +41,7 @@ module A {
4141
}
4242

4343
export module Point {
44-
>Point : typeof Point
44+
>Point : Point
4545

4646
var Origin = ""; // not an error since not exported
4747
>Origin : string

tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ enum enumdule {
88
}
99

1010
module enumdule {
11-
>enumdule : typeof enumdule
11+
>enumdule : enumdule
1212

1313
export class Point {
1414
>Point : Point
@@ -36,8 +36,8 @@ var y: { x: number; y: number };
3636

3737
var y = new enumdule.Point(0, 0);
3838
>y : { x: number; y: number; }
39-
>new enumdule.Point(0, 0) : Point
40-
>enumdule.Point : typeof Point
39+
>new enumdule.Point(0, 0) : enumdule.Point
40+
>enumdule.Point : typeof enumdule.Point
4141
>enumdule : typeof enumdule
42-
>Point : typeof Point
42+
>Point : typeof enumdule.Point
4343

0 commit comments

Comments
 (0)