Skip to content

Commit 73c94d0

Browse files
committed
Merge remote-tracking branch 'origin/master' into pathMappingModuleResolution
2 parents 635201c + ba0f7f5 commit 73c94d0

68 files changed

Lines changed: 1395 additions & 231 deletions

File tree

Some content is hidden

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

src/compiler/checker.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7954,31 +7954,12 @@ namespace ts {
79547954
return jsxElementType || anyType;
79557955
}
79567956

7957-
function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean {
7958-
if (lhs.kind !== rhs.kind) {
7959-
return false;
7960-
}
7961-
7962-
if (lhs.kind === SyntaxKind.Identifier) {
7963-
return (<Identifier>lhs).text === (<Identifier>rhs).text;
7964-
}
7965-
7966-
return (<QualifiedName>lhs).right.text === (<QualifiedName>rhs).right.text &&
7967-
tagNamesAreEquivalent((<QualifiedName>lhs).left, (<QualifiedName>rhs).left);
7968-
}
7969-
79707957
function checkJsxElement(node: JsxElement) {
79717958
// Check attributes
79727959
checkJsxOpeningLikeElement(node.openingElement);
79737960

7974-
// Check that the closing tag matches
7975-
if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) {
7976-
error(node.closingElement, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNode(node.openingElement.tagName));
7977-
}
7978-
else {
7979-
// Perform resolution on the closing tag so that rename/go to definition/etc work
7980-
getJsxElementTagSymbol(node.closingElement);
7981-
}
7961+
// Perform resolution on the closing tag so that rename/go to definition/etc work
7962+
getJsxElementTagSymbol(node.closingElement);
79827963

79837964
// Check children
79847965
for (const child of node.children) {

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,5 +2727,9 @@
27272727
"A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": {
27282728
"category": "Error",
27292729
"code": 17007
2730+
},
2731+
"JSX element '{0}' has no corresponding closing tag.": {
2732+
"category": "Error",
2733+
"code": 17008
27302734
}
27312735
}

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6990,7 +6990,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
69906990

69916991
write(text);
69926992
}
6993-
write(`], function(${exportFunctionForFile}, __moduleName) {`);
6993+
write(`], function(${exportFunctionForFile}) {`);
69946994
writeLine();
69956995
increaseIndent();
69966996
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);

src/compiler/parser.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3497,6 +3497,20 @@ namespace ts {
34973497
return finishNode(node);
34983498
}
34993499

3500+
function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean {
3501+
if (lhs.kind !== rhs.kind) {
3502+
return false;
3503+
}
3504+
3505+
if (lhs.kind === SyntaxKind.Identifier) {
3506+
return (<Identifier>lhs).text === (<Identifier>rhs).text;
3507+
}
3508+
3509+
return (<QualifiedName>lhs).right.text === (<QualifiedName>rhs).right.text &&
3510+
tagNamesAreEquivalent((<QualifiedName>lhs).left, (<QualifiedName>rhs).left);
3511+
}
3512+
3513+
35003514
function parseJsxElementOrSelfClosingElement(inExpressionContext: boolean): JsxElement | JsxSelfClosingElement {
35013515
const opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext);
35023516
let result: JsxElement | JsxSelfClosingElement;
@@ -3506,6 +3520,11 @@ namespace ts {
35063520

35073521
node.children = parseJsxChildren(node.openingElement.tagName);
35083522
node.closingElement = parseJsxClosingElement(inExpressionContext);
3523+
3524+
if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) {
3525+
parseErrorAtPosition(node.closingElement.pos, node.closingElement.end - node.closingElement.pos, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNodeFromSourceText(sourceText, node.openingElement.tagName));
3526+
}
3527+
35093528
result = finishNode(node);
35103529
}
35113530
else {
@@ -3565,10 +3584,13 @@ namespace ts {
35653584
while (true) {
35663585
token = scanner.reScanJsxToken();
35673586
if (token === SyntaxKind.LessThanSlashToken) {
3587+
// Closing tag
35683588
break;
35693589
}
35703590
else if (token === SyntaxKind.EndOfFileToken) {
3571-
parseErrorAtCurrentToken(Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNodeFromSourceText(sourceText, openingTagName));
3591+
// If we hit EOF, issue the error at the tag that lacks the closing element
3592+
// rather than at the end of the file (which is useless)
3593+
parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTagName));
35723594
break;
35733595
}
35743596
result.push(parseJsxChild());

src/lib/es6.d.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Symbol {
77
/** Returns the primitive value of the specified object. */
88
valueOf(): Object;
99

10-
[Symbol.toStringTag]: string;
10+
[Symbol.toStringTag]: "Symbol";
1111
}
1212

1313
interface SymbolConstructor {
@@ -565,7 +565,7 @@ interface IterableIterator<T> extends Iterator<T> {
565565
}
566566

567567
interface GeneratorFunction extends Function {
568-
568+
[Symbol.toStringTag]: "GeneratorFunction";
569569
}
570570

571571
interface GeneratorFunctionConstructor {
@@ -690,7 +690,7 @@ interface Math {
690690
*/
691691
cbrt(x: number): number;
692692

693-
[Symbol.toStringTag]: string;
693+
[Symbol.toStringTag]: "Math";
694694
}
695695

696696
interface Date {
@@ -807,7 +807,7 @@ interface Map<K, V> {
807807
size: number;
808808
values(): IterableIterator<V>;
809809
[Symbol.iterator]():IterableIterator<[K,V]>;
810-
[Symbol.toStringTag]: string;
810+
[Symbol.toStringTag]: "Map";
811811
}
812812

813813
interface MapConstructor {
@@ -824,7 +824,7 @@ interface WeakMap<K, V> {
824824
get(key: K): V;
825825
has(key: K): boolean;
826826
set(key: K, value?: V): WeakMap<K, V>;
827-
[Symbol.toStringTag]: string;
827+
[Symbol.toStringTag]: "WeakMap";
828828
}
829829

830830
interface WeakMapConstructor {
@@ -846,7 +846,7 @@ interface Set<T> {
846846
size: number;
847847
values(): IterableIterator<T>;
848848
[Symbol.iterator]():IterableIterator<T>;
849-
[Symbol.toStringTag]: string;
849+
[Symbol.toStringTag]: "Set";
850850
}
851851

852852
interface SetConstructor {
@@ -862,7 +862,7 @@ interface WeakSet<T> {
862862
clear(): void;
863863
delete(value: T): boolean;
864864
has(value: T): boolean;
865-
[Symbol.toStringTag]: string;
865+
[Symbol.toStringTag]: "WeakSet";
866866
}
867867

868868
interface WeakSetConstructor {
@@ -874,7 +874,7 @@ interface WeakSetConstructor {
874874
declare var WeakSet: WeakSetConstructor;
875875

876876
interface JSON {
877-
[Symbol.toStringTag]: string;
877+
[Symbol.toStringTag]: "JSON";
878878
}
879879

880880
/**
@@ -884,11 +884,11 @@ interface JSON {
884884
* buffer as needed.
885885
*/
886886
interface ArrayBuffer {
887-
[Symbol.toStringTag]: string;
887+
[Symbol.toStringTag]: "ArrayBuffer";
888888
}
889889

890890
interface DataView {
891-
[Symbol.toStringTag]: string;
891+
[Symbol.toStringTag]: "DataView";
892892
}
893893

894894
/**
@@ -909,6 +909,7 @@ interface Int8Array {
909909
*/
910910
values(): IterableIterator<number>;
911911
[Symbol.iterator](): IterableIterator<number>;
912+
[Symbol.toStringTag]: "Int8Array";
912913
}
913914

914915
interface Int8ArrayConstructor {
@@ -941,6 +942,7 @@ interface Uint8Array {
941942
*/
942943
values(): IterableIterator<number>;
943944
[Symbol.iterator](): IterableIterator<number>;
945+
[Symbol.toStringTag]: "UInt8Array";
944946
}
945947

946948
interface Uint8ArrayConstructor {
@@ -976,6 +978,7 @@ interface Uint8ClampedArray {
976978
values(): IterableIterator<number>;
977979

978980
[Symbol.iterator](): IterableIterator<number>;
981+
[Symbol.toStringTag]: "Uint8ClampedArray";
979982
}
980983

981984
interface Uint8ClampedArrayConstructor {
@@ -1013,6 +1016,7 @@ interface Int16Array {
10131016

10141017

10151018
[Symbol.iterator](): IterableIterator<number>;
1019+
[Symbol.toStringTag]: "Int16Array";
10161020
}
10171021

10181022
interface Int16ArrayConstructor {
@@ -1045,6 +1049,7 @@ interface Uint16Array {
10451049
*/
10461050
values(): IterableIterator<number>;
10471051
[Symbol.iterator](): IterableIterator<number>;
1052+
[Symbol.toStringTag]: "Uint16Array";
10481053
}
10491054

10501055
interface Uint16ArrayConstructor {
@@ -1077,6 +1082,7 @@ interface Int32Array {
10771082
*/
10781083
values(): IterableIterator<number>;
10791084
[Symbol.iterator](): IterableIterator<number>;
1085+
[Symbol.toStringTag]: "Int32Array";
10801086
}
10811087

10821088
interface Int32ArrayConstructor {
@@ -1109,6 +1115,7 @@ interface Uint32Array {
11091115
*/
11101116
values(): IterableIterator<number>;
11111117
[Symbol.iterator](): IterableIterator<number>;
1118+
[Symbol.toStringTag]: "Uint32Array";
11121119
}
11131120

11141121
interface Uint32ArrayConstructor {
@@ -1141,6 +1148,7 @@ interface Float32Array {
11411148
*/
11421149
values(): IterableIterator<number>;
11431150
[Symbol.iterator](): IterableIterator<number>;
1151+
[Symbol.toStringTag]: "Float32Array";
11441152
}
11451153

11461154
interface Float32ArrayConstructor {
@@ -1173,6 +1181,7 @@ interface Float64Array {
11731181
*/
11741182
values(): IterableIterator<number>;
11751183
[Symbol.iterator](): IterableIterator<number>;
1184+
[Symbol.toStringTag]: "Float64Array";
11761185
}
11771186

11781187
interface Float64ArrayConstructor {
@@ -1249,7 +1258,7 @@ interface Promise<T> {
12491258
catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
12501259
catch(onrejected?: (reason: any) => void): Promise<T>;
12511260

1252-
[Symbol.toStringTag]: string;
1261+
[Symbol.toStringTag]: "Promise";
12531262
}
12541263

12551264
interface PromiseConstructor {

tests/baselines/reference/aliasesInSystemModule1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module M {
1717

1818

1919
//// [aliasesInSystemModule1.js]
20-
System.register(['foo'], function(exports_1, __moduleName) {
20+
System.register(['foo'], function(exports_1) {
2121
"use strict";
2222
var alias;
2323
var cls, cls2, x, y, z, M;

tests/baselines/reference/aliasesInSystemModule2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module M {
1616
}
1717

1818
//// [aliasesInSystemModule2.js]
19-
System.register(["foo"], function(exports_1, __moduleName) {
19+
System.register(["foo"], function(exports_1) {
2020
"use strict";
2121
var foo_1;
2222
var cls, cls2, x, y, z, M;

tests/baselines/reference/allowSyntheticDefaultImports2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class Foo {
1010
}
1111

1212
//// [b.js]
13-
System.register([], function(exports_1, __moduleName) {
13+
System.register([], function(exports_1) {
1414
"use strict";
1515
var Foo;
1616
return {
@@ -26,7 +26,7 @@ System.register([], function(exports_1, __moduleName) {
2626
}
2727
});
2828
//// [a.js]
29-
System.register(["./b"], function(exports_1, __moduleName) {
29+
System.register(["./b"], function(exports_1) {
3030
"use strict";
3131
var b_1;
3232
var x;

tests/baselines/reference/allowSyntheticDefaultImports3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class Foo {
1111

1212

1313
//// [b.js]
14-
System.register([], function(exports_1, __moduleName) {
14+
System.register([], function(exports_1) {
1515
"use strict";
1616
var Foo;
1717
return {
@@ -27,7 +27,7 @@ System.register([], function(exports_1, __moduleName) {
2727
}
2828
});
2929
//// [a.js]
30-
System.register(["./b"], function(exports_1, __moduleName) {
30+
System.register(["./b"], function(exports_1) {
3131
"use strict";
3232
var b_1;
3333
var x;

tests/baselines/reference/allowSyntheticDefaultImports5.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export var x = new Foo();
1212

1313

1414
//// [a.js]
15-
System.register(["./b"], function(exports_1, __moduleName) {
15+
System.register(["./b"], function(exports_1) {
1616
"use strict";
1717
var b_1;
1818
var x;

0 commit comments

Comments
 (0)