diff --git a/lib/enu/diagnosticMessages.generated.json.lcg b/lib/enu/diagnosticMessages.generated.json.lcg
index de808d1e48ad5..528d373262863 100644
--- a/lib/enu/diagnosticMessages.generated.json.lcg
+++ b/lib/enu/diagnosticMessages.generated.json.lcg
@@ -843,6 +843,12 @@
+ -
+
+
+
+
+
-
@@ -1419,12 +1425,6 @@
- -
-
-
-
-
-
-
@@ -2445,6 +2445,12 @@
+ -
+
+
+
+
+
-
@@ -3003,12 +3009,6 @@
- -
-
-
-
-
-
-
@@ -3933,6 +3933,12 @@
+ -
+
+
+
+
+
-
@@ -3987,6 +3993,12 @@
+ -
+
+
+
+
+
-
@@ -6459,6 +6471,12 @@
+ -
+
+
+
+
+
-
@@ -7227,6 +7245,12 @@
+ -
+
+
+
+
+
-
diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts
index 26664f7d070e0..fdf506c6742ae 100644
--- a/lib/lib.dom.d.ts
+++ b/lib/lib.dom.d.ts
@@ -17348,7 +17348,8 @@ interface WorkerEventMap extends AbstractWorkerEventMap {
/** An interface of the Web Workers API represents a background task that can be easily created and can send messages back to its creator. Creating a worker is as simple as calling the Worker() constructor and specifying a script to be run in the worker thread. */
interface Worker extends EventTarget, AbstractWorker {
onmessage: ((this: Worker, ev: MessageEvent) => any) | null;
- postMessage(message: any, transfer?: Transferable[]): void;
+ postMessage(message: any, transfer: Transferable[]): void;
+ postMessage(message: any, options?: PostMessageOptions): void;
terminate(): void;
addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts
index 7d5c34ce6dba7..1c6feca6e61c5 100644
--- a/lib/lib.es5.d.ts
+++ b/lib/lib.es5.d.ts
@@ -533,7 +533,7 @@ interface Boolean {
interface BooleanConstructor {
new(value?: any): Boolean;
- (value?: T): value is Exclude;
+ (value?: T): boolean;
readonly prototype: Boolean;
}
diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts
index c7651851565fd..bdff3ef40c894 100644
--- a/lib/lib.webworker.d.ts
+++ b/lib/lib.webworker.d.ts
@@ -4251,7 +4251,8 @@ interface WorkerEventMap extends AbstractWorkerEventMap {
/** An interface of the Web Workers API represents a background task that can be easily created and can send messages back to its creator. Creating a worker is as simple as calling the Worker() constructor and specifying a script to be run in the worker thread. */
interface Worker extends EventTarget, AbstractWorker {
onmessage: ((this: Worker, ev: MessageEvent) => any) | null;
- postMessage(message: any, transfer?: Transferable[]): void;
+ postMessage(message: any, transfer: Transferable[]): void;
+ postMessage(message: any, options?: PostMessageOptions): void;
terminate(): void;
addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
diff --git a/lib/tsc.js b/lib/tsc.js
index b9ede744acb65..2cbf0416941d0 100644
--- a/lib/tsc.js
+++ b/lib/tsc.js
@@ -60,7 +60,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
var ts;
(function (ts) {
ts.versionMajorMinor = "3.5";
- ts.version = ts.versionMajorMinor + ".0-rc";
+ ts.version = ts.versionMajorMinor + ".1";
})(ts || (ts = {}));
(function (ts) {
ts.emptyArray = [];
@@ -251,7 +251,7 @@ var ts;
ts.firstDefinedIterator = firstDefinedIterator;
function zipWith(arrayA, arrayB, callback) {
var result = [];
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
for (var i = 0; i < arrayA.length; i++) {
result.push(callback(arrayA[i], arrayB[i], i));
}
@@ -259,7 +259,7 @@ var ts;
}
ts.zipWith = zipWith;
function zipToIterator(arrayA, arrayB) {
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
var i = 0;
return {
next: function () {
@@ -273,7 +273,7 @@ var ts;
}
ts.zipToIterator = zipToIterator;
function zipToMap(keys, values) {
- Debug.assert(keys.length === values.length);
+ ts.Debug.assert(keys.length === values.length);
var map = createMap();
for (var i = 0; i < keys.length; ++i) {
map.set(keys[i], values[i]);
@@ -337,7 +337,7 @@ var ts;
return result;
}
}
- return Debug.fail();
+ return ts.Debug.fail();
}
ts.findMap = findMap;
function contains(array, value, equalityComparer) {
@@ -745,7 +745,7 @@ var ts;
case 0:
continue;
case -1:
- return Debug.fail("Array is unsorted.");
+ return ts.Debug.fail("Array is unsorted.");
}
deduplicated.push(last = next);
}
@@ -806,11 +806,11 @@ var ts;
var result = [];
loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
if (offsetB > 0) {
- Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0);
}
loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
if (offsetA > startA) {
- Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0);
}
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
case -1:
@@ -948,7 +948,7 @@ var ts;
}
ts.firstOrUndefined = firstOrUndefined;
function first(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[0];
}
ts.first = first;
@@ -957,7 +957,7 @@ var ts;
}
ts.lastOrUndefined = lastOrUndefined;
function last(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[array.length - 1];
}
ts.last = last;
@@ -1231,7 +1231,7 @@ var ts;
function cast(value, test) {
if (value !== undefined && test(value))
return value;
- return Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + Debug.getFunctionName(test) + "'.");
+ return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
}
ts.cast = cast;
function noop(_) { }
@@ -1286,92 +1286,6 @@ var ts;
}
}
ts.compose = compose;
- var Debug;
- (function (Debug) {
- Debug.currentAssertionLevel = 0;
- Debug.isDebugging = false;
- function shouldAssert(level) {
- return Debug.currentAssertionLevel >= level;
- }
- Debug.shouldAssert = shouldAssert;
- function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
- if (!expression) {
- if (verboseDebugInfo) {
- message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
- }
- fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
- }
- }
- Debug.assert = assert;
- function assertEqual(a, b, msg, msg2) {
- if (a !== b) {
- var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
- fail("Expected " + a + " === " + b + ". " + message);
- }
- }
- Debug.assertEqual = assertEqual;
- function assertLessThan(a, b, msg) {
- if (a >= b) {
- fail("Expected " + a + " < " + b + ". " + (msg || ""));
- }
- }
- Debug.assertLessThan = assertLessThan;
- function assertLessThanOrEqual(a, b) {
- if (a > b) {
- fail("Expected " + a + " <= " + b);
- }
- }
- Debug.assertLessThanOrEqual = assertLessThanOrEqual;
- function assertGreaterThanOrEqual(a, b) {
- if (a < b) {
- fail("Expected " + a + " >= " + b);
- }
- }
- Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
- function fail(message, stackCrawlMark) {
- debugger;
- var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
- if (Error.captureStackTrace) {
- Error.captureStackTrace(e, stackCrawlMark || fail);
- }
- throw e;
- }
- Debug.fail = fail;
- function assertDefined(value, message) {
- if (value === undefined || value === null)
- return fail(message);
- return value;
- }
- Debug.assertDefined = assertDefined;
- function assertEachDefined(value, message) {
- for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
- var v = value_1[_i];
- assertDefined(v, message);
- }
- return value;
- }
- Debug.assertEachDefined = assertEachDefined;
- function assertNever(member, message, stackCrawlMark) {
- if (message === void 0) { message = "Illegal value:"; }
- var detail = typeof member === "object" && "kind" in member && "pos" in member ? "SyntaxKind: " + Debug.showSyntaxKind(member) : JSON.stringify(member);
- return fail(message + " " + detail, stackCrawlMark || assertNever);
- }
- Debug.assertNever = assertNever;
- function getFunctionName(func) {
- if (typeof func !== "function") {
- return "";
- }
- else if (func.hasOwnProperty("name")) {
- return func.name;
- }
- else {
- var text = Function.prototype.toString.call(func);
- var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
- return match ? match[1] : "";
- }
- }
- Debug.getFunctionName = getFunctionName;
- })(Debug = ts.Debug || (ts.Debug = {}));
function equateValues(a, b) {
return a === b;
}
@@ -1542,7 +1456,7 @@ var ts;
bestCandidate = candidate;
}
else {
- Debug.assert(distance < bestDistance);
+ ts.Debug.assert(distance < bestDistance);
bestDistance = distance;
bestCandidate = candidate;
}
@@ -1668,7 +1582,7 @@ var ts;
}
ts.patternText = patternText;
function matchedText(pattern, candidate) {
- Debug.assert(isPatternMatch(pattern, candidate));
+ ts.Debug.assert(isPatternMatch(pattern, candidate));
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
}
ts.matchedText = matchedText;
@@ -1786,6 +1700,234 @@ var ts;
}
})(ts || (ts = {}));
var ts;
+(function (ts) {
+ var Debug;
+ (function (Debug) {
+ Debug.currentAssertionLevel = 0;
+ Debug.isDebugging = false;
+ function shouldAssert(level) {
+ return Debug.currentAssertionLevel >= level;
+ }
+ Debug.shouldAssert = shouldAssert;
+ function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
+ if (!expression) {
+ if (verboseDebugInfo) {
+ message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
+ }
+ fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
+ }
+ }
+ Debug.assert = assert;
+ function assertEqual(a, b, msg, msg2) {
+ if (a !== b) {
+ var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
+ fail("Expected " + a + " === " + b + ". " + message);
+ }
+ }
+ Debug.assertEqual = assertEqual;
+ function assertLessThan(a, b, msg) {
+ if (a >= b) {
+ fail("Expected " + a + " < " + b + ". " + (msg || ""));
+ }
+ }
+ Debug.assertLessThan = assertLessThan;
+ function assertLessThanOrEqual(a, b) {
+ if (a > b) {
+ fail("Expected " + a + " <= " + b);
+ }
+ }
+ Debug.assertLessThanOrEqual = assertLessThanOrEqual;
+ function assertGreaterThanOrEqual(a, b) {
+ if (a < b) {
+ fail("Expected " + a + " >= " + b);
+ }
+ }
+ Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
+ function fail(message, stackCrawlMark) {
+ debugger;
+ var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(e, stackCrawlMark || fail);
+ }
+ throw e;
+ }
+ Debug.fail = fail;
+ function assertDefined(value, message) {
+ if (value === undefined || value === null)
+ return fail(message);
+ return value;
+ }
+ Debug.assertDefined = assertDefined;
+ function assertEachDefined(value, message) {
+ for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
+ var v = value_1[_i];
+ assertDefined(v, message);
+ }
+ return value;
+ }
+ Debug.assertEachDefined = assertEachDefined;
+ function assertNever(member, message, stackCrawlMark) {
+ if (message === void 0) { message = "Illegal value:"; }
+ var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
+ return fail(message + " " + detail, stackCrawlMark || assertNever);
+ }
+ Debug.assertNever = assertNever;
+ function getFunctionName(func) {
+ if (typeof func !== "function") {
+ return "";
+ }
+ else if (func.hasOwnProperty("name")) {
+ return func.name;
+ }
+ else {
+ var text = Function.prototype.toString.call(func);
+ var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
+ return match ? match[1] : "";
+ }
+ }
+ Debug.getFunctionName = getFunctionName;
+ function formatSymbol(symbol) {
+ return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
+ }
+ Debug.formatSymbol = formatSymbol;
+ function formatEnum(value, enumObject, isFlags) {
+ if (value === void 0) { value = 0; }
+ var members = getEnumMembers(enumObject);
+ if (value === 0) {
+ return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
+ }
+ if (isFlags) {
+ var result = "";
+ var remainingFlags = value;
+ for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
+ var _a = members[i], enumValue = _a[0], enumName = _a[1];
+ if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
+ remainingFlags &= ~enumValue;
+ result = "" + enumName + (result ? "|" : "") + result;
+ }
+ }
+ if (remainingFlags === 0) {
+ return result;
+ }
+ }
+ else {
+ for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
+ var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
+ if (enumValue === value) {
+ return enumName;
+ }
+ }
+ }
+ return value.toString();
+ }
+ Debug.formatEnum = formatEnum;
+ function getEnumMembers(enumObject) {
+ var result = [];
+ for (var name in enumObject) {
+ var value = enumObject[name];
+ if (typeof value === "number") {
+ result.push([value, name]);
+ }
+ }
+ return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
+ }
+ function formatSyntaxKind(kind) {
+ return formatEnum(kind, ts.SyntaxKind, false);
+ }
+ Debug.formatSyntaxKind = formatSyntaxKind;
+ function formatNodeFlags(flags) {
+ return formatEnum(flags, ts.NodeFlags, true);
+ }
+ Debug.formatNodeFlags = formatNodeFlags;
+ function formatModifierFlags(flags) {
+ return formatEnum(flags, ts.ModifierFlags, true);
+ }
+ Debug.formatModifierFlags = formatModifierFlags;
+ function formatTransformFlags(flags) {
+ return formatEnum(flags, ts.TransformFlags, true);
+ }
+ Debug.formatTransformFlags = formatTransformFlags;
+ function formatEmitFlags(flags) {
+ return formatEnum(flags, ts.EmitFlags, true);
+ }
+ Debug.formatEmitFlags = formatEmitFlags;
+ function formatSymbolFlags(flags) {
+ return formatEnum(flags, ts.SymbolFlags, true);
+ }
+ Debug.formatSymbolFlags = formatSymbolFlags;
+ function formatTypeFlags(flags) {
+ return formatEnum(flags, ts.TypeFlags, true);
+ }
+ Debug.formatTypeFlags = formatTypeFlags;
+ function formatObjectFlags(flags) {
+ return formatEnum(flags, ts.ObjectFlags, true);
+ }
+ Debug.formatObjectFlags = formatObjectFlags;
+ function failBadSyntaxKind(node, message) {
+ return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
+ }
+ Debug.failBadSyntaxKind = failBadSyntaxKind;
+ Debug.assertEachNode = shouldAssert(1)
+ ? function (nodes, test, message) { return assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertEachNode); }
+ : ts.noop;
+ Debug.assertNode = shouldAssert(1)
+ ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); }
+ : ts.noop;
+ Debug.assertOptionalNode = shouldAssert(1)
+ ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
+ : ts.noop;
+ Debug.assertOptionalToken = shouldAssert(1)
+ ? function (node, kind, message) { return assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
+ : ts.noop;
+ Debug.assertMissingNode = shouldAssert(1)
+ ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
+ : ts.noop;
+ var isDebugInfoEnabled = false;
+ function enableDebugInfo() {
+ if (isDebugInfoEnabled)
+ return;
+ Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
+ __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
+ });
+ Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
+ __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
+ __debugObjectFlags: { get: function () { return this.flags & 524288 ? formatObjectFlags(this.objectFlags) : ""; } },
+ __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
+ });
+ var nodeConstructors = [
+ ts.objectAllocator.getNodeConstructor(),
+ ts.objectAllocator.getIdentifierConstructor(),
+ ts.objectAllocator.getTokenConstructor(),
+ ts.objectAllocator.getSourceFileConstructor()
+ ];
+ for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
+ var ctor = nodeConstructors_1[_i];
+ if (!ctor.prototype.hasOwnProperty("__debugKind")) {
+ Object.defineProperties(ctor.prototype, {
+ __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
+ __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
+ __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
+ __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
+ __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
+ __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
+ __debugGetText: {
+ value: function (includeTrivia) {
+ if (ts.nodeIsSynthesized(this))
+ return "";
+ var parseNode = ts.getParseTreeNode(this);
+ var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
+ return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
+ }
+ }
+ });
+ }
+ }
+ isDebugInfoEnabled = true;
+ }
+ Debug.enableDebugInfo = enableDebugInfo;
+ })(Debug = ts.Debug || (ts.Debug = {}));
+})(ts || (ts = {}));
+var ts;
(function (ts) {
ts.timestamp = typeof performance !== "undefined" && performance.now ? function () { return performance.now(); } : Date.now ? Date.now : function () { return +(new Date()); };
})(ts || (ts = {}));
@@ -3267,7 +3409,7 @@ var ts;
Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."),
Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
- Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", "Cannot compile namespaces when the '--isolatedModules' flag is provided."),
+ All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."),
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."),
A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
@@ -4054,7 +4196,6 @@ var ts;
Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."),
Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
Multiple_consecutive_numeric_separators_are_not_permitted: diag(6189, ts.DiagnosticCategory.Error, "Multiple_consecutive_numeric_separators_are_not_permitted_6189", "Multiple consecutive numeric separators are not permitted."),
- Found_package_json_at_0_Package_ID_is_1: diag(6190, ts.DiagnosticCategory.Message, "Found_package_json_at_0_Package_ID_is_1_6190", "Found 'package.json' at '{0}'. Package ID is '{1}'."),
Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: diag(6191, ts.DiagnosticCategory.Message, "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191", "Whether to keep outdated console output in watch mode instead of clearing the screen."),
All_imports_in_import_declaration_are_unused: diag(6192, ts.DiagnosticCategory.Error, "All_imports_in_import_declaration_are_unused_6192", "All imports in import declaration are unused.", true),
Found_1_error_Watching_for_file_changes: diag(6193, ts.DiagnosticCategory.Message, "Found_1_error_Watching_for_file_changes_6193", "Found 1 error. Watching for file changes."),
@@ -4081,6 +4222,9 @@ var ts;
Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."),
Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
+ Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"),
+ Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"),
+ package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."),
Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
@@ -4170,6 +4314,8 @@ var ts;
_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."),
Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1: diag(7051, ts.DiagnosticCategory.Error, "Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1_7051", "Parameter has a name but no type. Did you mean '{0}: {1}'?"),
Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1: diag(7052, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1_7052", "Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}' ?"),
+ Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: diag(7053, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053", "Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'."),
+ No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1: diag(7054, ts.DiagnosticCategory.Error, "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054", "No index signature with a parameter of type '{0}' was found on type '{1}'."),
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."),
@@ -7838,7 +7984,7 @@ var ts;
}
ts.isFunctionSymbol = isFunctionSymbol;
function importFromModuleSpecifier(node) {
- return tryGetImportFromModuleSpecifier(node) || ts.Debug.fail(ts.Debug.showSyntaxKind(node.parent));
+ return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
}
ts.importFromModuleSpecifier = importFromModuleSpecifier;
function tryGetImportFromModuleSpecifier(node) {
@@ -9609,74 +9755,6 @@ var ts;
return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
- function formatEnum(value, enumObject, isFlags) {
- if (value === void 0) { value = 0; }
- var members = getEnumMembers(enumObject);
- if (value === 0) {
- return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
- }
- if (isFlags) {
- var result = "";
- var remainingFlags = value;
- for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
- var _a = members[i], enumValue = _a[0], enumName = _a[1];
- if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
- remainingFlags &= ~enumValue;
- result = "" + enumName + (result ? ", " : "") + result;
- }
- }
- if (remainingFlags === 0) {
- return result;
- }
- }
- else {
- for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
- var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
- if (enumValue === value) {
- return enumName;
- }
- }
- }
- return value.toString();
- }
- function getEnumMembers(enumObject) {
- var result = [];
- for (var name in enumObject) {
- var value = enumObject[name];
- if (typeof value === "number") {
- result.push([value, name]);
- }
- }
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
- }
- function formatSyntaxKind(kind) {
- return formatEnum(kind, ts.SyntaxKind, false);
- }
- ts.formatSyntaxKind = formatSyntaxKind;
- function formatModifierFlags(flags) {
- return formatEnum(flags, ts.ModifierFlags, true);
- }
- ts.formatModifierFlags = formatModifierFlags;
- function formatTransformFlags(flags) {
- return formatEnum(flags, ts.TransformFlags, true);
- }
- ts.formatTransformFlags = formatTransformFlags;
- function formatEmitFlags(flags) {
- return formatEnum(flags, ts.EmitFlags, true);
- }
- ts.formatEmitFlags = formatEmitFlags;
- function formatSymbolFlags(flags) {
- return formatEnum(flags, ts.SymbolFlags, true);
- }
- ts.formatSymbolFlags = formatSymbolFlags;
- function formatTypeFlags(flags) {
- return formatEnum(flags, ts.TypeFlags, true);
- }
- ts.formatTypeFlags = formatTypeFlags;
- function formatObjectFlags(flags) {
- return formatEnum(flags, ts.ObjectFlags, true);
- }
- ts.formatObjectFlags = formatObjectFlags;
function createRange(pos, end) {
if (end === void 0) { end = pos; }
ts.Debug.assert(end >= pos || end === -1);
@@ -12398,6 +12476,15 @@ var ts;
return root + pathComponents.slice(1).join(ts.directorySeparator);
}
ts.getPathFromPathComponents = getPathFromPathComponents;
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
+ }
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
+ function getPathWithoutRoot(pathComponents) {
+ if (pathComponents.length === 0)
+ return "";
+ return pathComponents.slice(1).join(ts.directorySeparator);
+ }
})(ts || (ts = {}));
(function (ts) {
function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
@@ -12427,7 +12514,7 @@ var ts;
}
ts.getRelativePathFromFile = getRelativePathFromFile;
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
- Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
+ ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
@@ -12962,31 +13049,8 @@ var ts;
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
}
ts.changeAnyExtension = changeAnyExtension;
- var Debug;
- (function (Debug) {
- function showSymbol(symbol) {
- var symbolFlags = ts.SymbolFlags;
- return "{ flags: " + (symbolFlags ? showFlags(symbol.flags, symbolFlags) : symbol.flags) + "; declarations: " + ts.map(symbol.declarations, showSyntaxKind) + " }";
- }
- Debug.showSymbol = showSymbol;
- function showFlags(flags, flagsEnum) {
- var out = [];
- for (var pow = 0; pow <= 30; pow++) {
- var n = 1 << pow;
- if (flags & n) {
- out.push(flagsEnum[n]);
- }
- }
- return out.join("|");
- }
- function showSyntaxKind(node) {
- var syntaxKind = ts.SyntaxKind;
- return syntaxKind ? syntaxKind[node.kind] : node.kind.toString();
- }
- Debug.showSyntaxKind = showSyntaxKind;
- })(Debug = ts.Debug || (ts.Debug = {}));
function tryParsePattern(pattern) {
- Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
+ ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
var indexOfStar = pattern.indexOf("*");
return indexOfStar === -1 ? undefined : {
prefix: pattern.substr(0, indexOfStar),
@@ -13008,7 +13072,7 @@ var ts;
ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson;
function extensionFromPath(path) {
var ext = tryGetExtensionFromPath(path);
- return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension.");
+ return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
}
ts.extensionFromPath = extensionFromPath;
function isAnySupportedFileExtension(path) {
@@ -13072,7 +13136,7 @@ var ts;
ts.matchPatternOrExact = matchPatternOrExact;
function sliceAfter(arr, value) {
var index = arr.indexOf(value);
- Debug.assert(index !== -1);
+ ts.Debug.assert(index !== -1);
return arr.slice(index);
}
ts.sliceAfter = sliceAfter;
@@ -13090,7 +13154,7 @@ var ts;
}
ts.addRelatedInfo = addRelatedInfo;
function minAndMax(arr, getValue) {
- Debug.assert(arr.length !== 0);
+ ts.Debug.assert(arr.length !== 0);
var min = getValue(arr[0]);
var max = min;
for (var i = 1; i < arr.length; i++) {
@@ -20948,7 +21012,7 @@ var ts;
if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) {
extendedConfigPath = extendedConfigPath + ".json";
if (!host.fileExists(extendedConfigPath)) {
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
}
@@ -20958,7 +21022,7 @@ var ts;
if (resolved.resolvedModule) {
return resolved.resolvedModule.resolvedFileName;
}
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
@@ -21333,7 +21397,18 @@ var ts;
return !!compilerOptions.traceResolution && host.trace !== undefined;
}
ts.isTraceEnabled = isTraceEnabled;
- function withPackageId(packageId, r) {
+ function withPackageId(packageInfo, r) {
+ var packageId;
+ if (r && packageInfo) {
+ var packageJsonContent = packageInfo.packageJsonContent;
+ if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
+ packageId = {
+ name: packageJsonContent.name,
+ subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
+ version: packageJsonContent.version
+ };
+ }
+ }
return r && { path: r.path, extension: r.ext, packageId: packageId };
}
function noPackageId(r) {
@@ -21384,8 +21459,15 @@ var ts;
}
function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
- if (fileName === undefined)
+ if (fileName === undefined) {
+ return;
+ }
+ if (!fileName) {
+ if (state.traceEnabled) {
+ trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
+ }
return;
+ }
var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
@@ -21526,7 +21608,12 @@ var ts;
var fileName = resolved.fileName, packageId = resolved.packageId;
var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
if (traceEnabled) {
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ if (packageId) {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary);
+ }
+ else {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ }
}
resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
}
@@ -21774,7 +21861,12 @@ var ts;
}
if (traceEnabled) {
if (result.resolvedModule) {
- trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ if (result.resolvedModule.packageId) {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2, moduleName, result.resolvedModule.resolvedFileName, ts.packageIdToString(result.resolvedModule.packageId));
+ }
+ else {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ }
}
else {
trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
@@ -21969,10 +22061,9 @@ var ts;
}
var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
if (resolvedFromFile) {
- var nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
- var packageInfo = nm && getPackageJsonInfo(nm.packageDirectory, nm.subModuleName, false, state);
- var packageId = packageInfo && packageInfo.packageId;
- return withPackageId(packageId, resolvedFromFile);
+ var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
+ var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, false, state) : undefined;
+ return withPackageId(packageInfo, resolvedFromFile);
}
}
if (!onlyRecordFailures) {
@@ -22002,26 +22093,12 @@ var ts;
if (path.charCodeAt(indexAfterNodeModules) === 64) {
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
}
- var packageDirectory = path.slice(0, indexAfterPackageName);
- var subModuleName = ts.removeExtension(path.slice(indexAfterPackageName + 1), resolved.ext) + ".d.ts";
- return { packageDirectory: packageDirectory, subModuleName: subModuleName };
+ return path.slice(0, indexAfterPackageName);
}
function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
}
- function addExtensionAndIndex(path) {
- if (path === "") {
- return "index.d.ts";
- }
- if (ts.endsWith(path, ".d.ts")) {
- return path;
- }
- if (path === "index" || ts.endsWith(path, "/index")) {
- return path + ".d.ts";
- }
- return path + "/index.d.ts";
- }
function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
}
@@ -22085,52 +22162,22 @@ var ts;
}
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
if (considerPackageJson === void 0) { considerPackageJson = true; }
- var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, "", onlyRecordFailures, state) : undefined;
- var packageId = packageInfo && packageInfo.packageId;
+ var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
var versionPaths = packageInfo && packageInfo.versionPaths;
- return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
+ return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
}
- function getPackageJsonInfo(packageDirectory, subModuleName, onlyRecordFailures, state) {
+ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
var host = state.host, traceEnabled = state.traceEnabled;
var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
if (directoryExists && host.fileExists(packageJsonPath)) {
var packageJsonContent = ts.readJson(packageJsonPath, host);
- if (subModuleName === "") {
- var path = readPackageJsonTypesFields(packageJsonContent, packageDirectory, state);
- if (typeof path === "string") {
- subModuleName = addExtensionAndIndex(path.substring(packageDirectory.length + 1));
- }
- else {
- var jsPath = readPackageJsonMainField(packageJsonContent, packageDirectory, state);
- if (typeof jsPath === "string" && jsPath.length > packageDirectory.length) {
- var potentialSubModule_1 = jsPath.substring(packageDirectory.length + 1);
- subModuleName = (ts.forEach(ts.supportedJSExtensions, function (extension) {
- return ts.tryRemoveExtension(potentialSubModule_1, extension);
- }) || potentialSubModule_1) + ".d.ts";
- }
- else {
- subModuleName = "index.d.ts";
- }
- }
- }
- if (!ts.endsWith(subModuleName, ".d.ts")) {
- subModuleName = addExtensionAndIndex(subModuleName);
- }
- var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
- var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string"
- ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version }
- : undefined;
if (traceEnabled) {
- if (packageId) {
- trace(host, ts.Diagnostics.Found_package_json_at_0_Package_ID_is_1, packageJsonPath, ts.packageIdToString(packageId));
- }
- else {
- trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
- }
+ trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
}
- return { packageJsonContent: packageJsonContent, packageId: packageId, versionPaths: versionPaths };
+ var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
+ return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
}
else {
if (directoryExists && traceEnabled) {
@@ -22259,36 +22306,30 @@ var ts;
}
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
- var packageJsonContent;
- var packageId;
- var versionPaths;
- var packageInfo = getPackageJsonInfo(candidate, "", !nodeModulesDirectoryExists, state);
+ var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
if (packageInfo) {
- (packageJsonContent = packageInfo.packageJsonContent, packageId = packageInfo.packageId, versionPaths = packageInfo.versionPaths);
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
if (fromFile) {
return noPackageId(fromFile);
}
- var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, fromDirectory);
+ var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
+ return withPackageId(packageInfo, fromDirectory);
}
var loader = function (extensions, candidate, onlyRecordFailures, state) {
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
- loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, pathAndExtension);
+ loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
+ return withPackageId(packageInfo, pathAndExtension);
};
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
if (rest !== "") {
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
- var packageInfo_1 = getPackageJsonInfo(packageDirectory, rest, !nodeModulesDirectoryExists, state);
- if (packageInfo_1)
- (packageId = packageInfo_1.packageId, versionPaths = packageInfo_1.versionPaths);
- if (versionPaths) {
+ packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
+ if (packageInfo && packageInfo.versionPaths) {
if (state.traceEnabled) {
- trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, rest);
+ trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest);
}
var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, versionPaths.paths, loader, !packageDirectoryExists, state);
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
if (fromPaths) {
return fromPaths.value;
}
@@ -24374,7 +24415,7 @@ var ts;
}
break;
default:
- ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer));
+ ts.Debug.failBadSyntaxKind(thisContainer);
}
}
function bindSpecialPropertyDeclaration(node) {
@@ -24422,7 +24463,7 @@ var ts;
}
node.left.parent = node;
node.right.parent = node;
- if (ts.isIdentifier(lhs.expression) && container === file && isNameOfExportsOrModuleExportsAliasDeclaration(file, lhs.expression)) {
+ if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) {
bindExportsPropertyAssignment(node);
}
else {
@@ -24716,20 +24757,29 @@ var ts;
}
}
function isExportsOrModuleExportsOrAlias(sourceFile, node) {
- return ts.isExportsIdentifier(node) ||
- ts.isModuleExportsPropertyAccessExpression(node) ||
- ts.isIdentifier(node) && isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node);
+ var i = 0;
+ var q = [node];
+ while (q.length && i < 100) {
+ i++;
+ node = q.shift();
+ if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) {
+ return true;
+ }
+ else if (ts.isIdentifier(node)) {
+ var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
+ if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
+ var init = symbol.valueDeclaration.initializer;
+ q.push(init);
+ if (ts.isAssignmentExpression(init, true)) {
+ q.push(init.left);
+ q.push(init.right);
+ }
+ }
+ }
+ }
+ return false;
}
ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
- function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) {
- var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
- return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) &&
- !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer);
- }
- function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) {
- return isExportsOrModuleExportsOrAlias(sourceFile, node) ||
- (ts.isAssignmentExpression(node, true) && (isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.left) || isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.right)));
- }
function lookupSymbolForNameWorker(container, name) {
var local = container.locals && container.locals.get(name);
if (local) {
@@ -25721,6 +25771,10 @@ var ts;
node = ts.getParseTreeNode(node);
return node ? getTypeOfNode(node) : errorType;
},
+ getTypeOfAssignmentPattern: function (nodeIn) {
+ var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
+ return node && getTypeOfAssignmentPattern(node) || errorType;
+ },
getPropertySymbolOfDestructuringAssignment: function (locationIn) {
var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
@@ -28318,7 +28372,7 @@ var ts;
context.approximateLength += 6;
return ts.createKeywordTypeNode(137);
}
- if (type.flags & 262144 && type.isThisType) {
+ if (isThisTypeParameter(type)) {
if (context.flags & 4194304) {
if (!context.encounteredError && !(context.flags & 32768)) {
context.encounteredError = true;
@@ -28967,6 +29021,11 @@ var ts;
function lookupTypeParameterNodes(chain, index, context) {
ts.Debug.assert(chain && 0 <= index && index < chain.length);
var symbol = chain[index];
+ var symbolId = "" + getSymbolId(symbol);
+ if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
+ return undefined;
+ }
+ (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
var typeParameterNodes;
if (context.flags & 512 && index < (chain.length - 1)) {
var parentSymbol = symbol;
@@ -29800,7 +29859,7 @@ var ts;
return type;
}
else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(declaredType, declaration, type);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(undefined, declaredType, declaration, type);
}
}
return declaredType;
@@ -30078,7 +30137,7 @@ var ts;
type = getTypeOfEnumMember(symbol);
}
else {
- return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol));
+ return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
}
if (!popTypeResolution()) {
if (symbol.flags & 512) {
@@ -31164,9 +31223,10 @@ var ts;
var s = signature;
if (unionSignatures.length > 1) {
var thisParameter = signature.thisParameter;
- if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) {
+ var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
+ if (firstThisParameterOfUnionSignatures) {
var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2);
- thisParameter = createSymbolWithType(signature.thisParameter, thisType);
+ thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
}
s = createUnionSignature(signature, unionSignatures);
s.thisParameter = thisParameter;
@@ -31675,15 +31735,19 @@ var ts;
function getConstraintOfIndexedAccess(type) {
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
}
+ function getSimplifiedTypeOrConstraint(type) {
+ var simplified = getSimplifiedType(type, false);
+ return simplified !== type ? simplified : getConstraintOfType(type);
+ }
function getConstraintFromIndexedAccess(type) {
- var indexConstraint = getConstraintOfType(type.indexType);
+ var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
if (indexConstraint && indexConstraint !== type.indexType) {
var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
if (indexedAccess) {
return indexedAccess;
}
}
- var objectConstraint = getConstraintOfType(type.objectType);
+ var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
if (objectConstraint && objectConstraint !== type.objectType) {
return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
}
@@ -33446,6 +33510,14 @@ var ts;
types[index] = getUnionTypeFromSortedList(result, 65536);
return true;
}
+ function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
+ var result = createType(2097152);
+ result.objectFlags = getPropagatingFlagsOfTypes(types, 98304);
+ result.types = types;
+ result.aliasSymbol = aliasSymbol;
+ result.aliasTypeArguments = aliasTypeArguments;
+ return result;
+ }
function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
var typeSet = [];
var includes = addTypesToIntersection(typeSet, 0, types);
@@ -33473,25 +33545,30 @@ var ts;
if (typeSet.length === 1) {
return typeSet[0];
}
- if (includes & 1048576) {
- if (intersectUnionsOfPrimitiveTypes(typeSet)) {
- return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
- }
- var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576) !== 0; });
- var unionType = typeSet[unionIndex_1];
- return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments);
- }
var id = getTypeListId(typeSet);
- var type = intersectionTypes.get(id);
- if (!type) {
- type = createType(2097152);
- intersectionTypes.set(id, type);
- type.objectFlags = getPropagatingFlagsOfTypes(typeSet, 98304);
- type.types = typeSet;
- type.aliasSymbol = aliasSymbol;
- type.aliasTypeArguments = aliasTypeArguments;
+ var result = intersectionTypes.get(id);
+ if (!result) {
+ if (includes & 1048576) {
+ if (intersectUnionsOfPrimitiveTypes(typeSet)) {
+ result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ else {
+ var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 ? t.types.length : 1); }, 1);
+ if (size >= 100000) {
+ error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
+ return errorType;
+ }
+ var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576) !== 0; });
+ var unionType = typeSet[unionIndex_1];
+ result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments);
+ }
+ }
+ else {
+ result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ intersectionTypes.set(id, result);
}
- return type;
+ return result;
}
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
@@ -33615,7 +33692,7 @@ var ts;
}
return false;
}
- function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, accessNode, accessFlags) {
+ function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
var accessExpression = accessNode && accessNode.kind === 191 ? accessNode : undefined;
var propName = isTypeUsableAsPropertyName(indexType) ?
getPropertyNameFromType(indexType) :
@@ -33652,6 +33729,7 @@ var ts;
error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
}
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1));
return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
}
}
@@ -33673,13 +33751,7 @@ var ts;
error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
return indexInfo.type;
}
- if (indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
- if (accessExpression) {
- error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
- return indexInfo.type;
- }
- return undefined;
- }
+ errorIfWritingToReadonlyIndex(indexInfo);
return indexInfo.type;
}
if (indexType.flags & 131072) {
@@ -33692,7 +33764,7 @@ var ts;
if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418)) {
error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
- else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
+ else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
}
@@ -33712,7 +33784,25 @@ var ts;
error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion_1);
}
else {
- error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType));
+ var errorInfo = void 0;
+ if (indexType.flags & 1024) {
+ errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 8192) {
+ var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
+ errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 128) {
+ errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & 256) {
+ errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & (8 | 4)) {
+ errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
+ }
+ errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType));
+ diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
}
}
}
@@ -33739,6 +33829,11 @@ var ts;
return indexType;
}
return undefined;
+ function errorIfWritingToReadonlyIndex(indexInfo) {
+ if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
+ error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
+ }
+ }
}
function getIndexNodeForAccessExpression(accessNode) {
return accessNode.kind === 191
@@ -33755,6 +33850,9 @@ var ts;
function isGenericIndexType(type) {
return maybeTypeOfKind(type, 58982400 | 4194304);
}
+ function isThisTypeParameter(type) {
+ return !!(type.flags & 262144 && type.isThisType);
+ }
function getSimplifiedType(type, writing) {
return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type, writing) :
type.flags & 16777216 ? getSimplifiedConditionalType(type, writing) :
@@ -33854,7 +33952,7 @@ var ts;
var wasMissingProp = false;
for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
var t = _a[_i];
- var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, accessNode, accessFlags);
+ var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
if (propType) {
propTypes.push(propType);
}
@@ -33870,7 +33968,7 @@ var ts;
}
return accessFlags & 2 ? getIntersectionType(propTypes) : getUnionType(propTypes);
}
- return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, accessNode, accessFlags | 4);
+ return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, false, accessNode, accessFlags | 4);
}
function getTypeFromIndexedAccessTypeNode(node) {
var links = getNodeLinks(node);
@@ -36126,8 +36224,7 @@ var ts;
return result;
}
}
- var simplified = getSimplifiedType(target.type, false);
- var constraint = simplified !== target.type ? simplified : getConstraintOfType(target.type);
+ var constraint = getSimplifiedTypeOrConstraint(target.type);
if (constraint) {
if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1) {
return -1;
@@ -39193,7 +39290,7 @@ var ts;
return !assumeTrue;
}
function narrowByInKeyword(type, literal, assumeTrue) {
- if ((type.flags & (1048576 | 524288)) || (type.flags & 262144 && type.isThisType)) {
+ if (type.flags & (1048576 | 524288) || isThisTypeParameter(type)) {
var propName_1 = ts.escapeLeadingUnderscores(literal.text);
return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
}
@@ -40458,8 +40555,8 @@ var ts;
var type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
if (type) {
if (!hasNonBindableDynamicName(element)) {
- var symbolName_2 = getSymbolOfNode(element).escapedName;
- var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_2);
+ var symbolName_3 = getSymbolOfNode(element).escapedName;
+ var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
if (propertyType) {
return propertyType;
}
@@ -41668,7 +41765,7 @@ var ts;
return anyType;
}
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
- reportNonexistentProperty(right, leftType.flags & 262144 && leftType.isThisType ? apparentType : leftType);
+ reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
}
return errorType;
}
@@ -41989,7 +42086,7 @@ var ts;
}
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
var accessFlags = ts.isAssignmentTarget(node) ?
- 2 | (isGenericObjectType(objectType) ? 1 : 0) :
+ 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) :
0;
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
return checkIndexedAccessIndexType(indexedAccessType, node);
@@ -44150,14 +44247,15 @@ var ts;
if (strictNullChecks && properties.length === 0) {
return checkNonNullType(sourceType, node);
}
- for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
- var p = properties_4[_i];
- checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis);
+ for (var i = 0; i < properties.length; i++) {
+ checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
}
return sourceType;
}
- function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) {
+ function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
if (rightIsThis === void 0) { rightIsThis = false; }
+ var properties = node.properties;
+ var property = properties[propertyIndex];
if (property.kind === 276 || property.kind === 277) {
var name = property.name;
var exprType = getLiteralTypeFromPropertyName(name);
@@ -44174,18 +44272,26 @@ var ts;
return checkDestructuringAssignment(property.kind === 277 ? property : property.initializer, type);
}
else if (property.kind === 278) {
- if (languageVersion < 8) {
- checkExternalEmitHelpers(property, 4);
+ if (propertyIndex < properties.length - 1) {
+ error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
}
- var nonRestNames = [];
- if (allProperties) {
- for (var i = 0; i < allProperties.length - 1; i++) {
- nonRestNames.push(allProperties[i].name);
+ else {
+ if (languageVersion < 8) {
+ checkExternalEmitHelpers(property, 4);
+ }
+ var nonRestNames = [];
+ if (allProperties) {
+ for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
+ var otherProperty = allProperties_1[_i];
+ if (!ts.isSpreadAssignment(otherProperty)) {
+ nonRestNames.push(otherProperty.name);
+ }
+ }
}
+ var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
+ checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
+ return checkDestructuringAssignment(property.expression, type);
}
- var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
- checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
- return checkDestructuringAssignment(property.expression, type);
}
else {
error(property, ts.Diagnostics.Property_assignment_expected);
@@ -45888,7 +45994,7 @@ var ts;
case 254:
return 1;
default:
- return ts.Debug.fail(ts.Debug.showSyntaxKind(d));
+ return ts.Debug.failBadSyntaxKind(d);
}
}
}
@@ -46815,7 +46921,7 @@ var ts;
if (type !== errorType && declarationType !== errorType &&
!isTypeIdenticalTo(type, declarationType) &&
!(symbol.flags & 67108864)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
}
if (node.initializer) {
checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined);
@@ -46833,12 +46939,16 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) {
+ function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
var message = nextDeclaration.kind === 155 || nextDeclaration.kind === 154
? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
: ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
- error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType));
+ var declName = ts.declarationNameToString(nextDeclarationName);
+ var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
+ if (firstDeclaration) {
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
+ }
}
function areDeclarationFlagsIdentical(left, right) {
if ((left.kind === 152 && right.kind === 238) ||
@@ -47752,8 +47862,8 @@ var ts;
for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
var base = baseTypes_2[_i];
var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
- for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) {
- var prop = properties_5[_a];
+ for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) {
+ var prop = properties_4[_a];
var existing = seen.get(prop.escapedName);
if (!existing) {
seen.set(prop.escapedName, { prop: prop, containingType: base });
@@ -49208,7 +49318,7 @@ var ts;
}
return errorType;
}
- function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) {
+ function getTypeOfAssignmentPattern(expr) {
ts.Debug.assert(expr.kind === 189 || expr.kind === 188);
if (expr.parent.kind === 228) {
var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier);
@@ -49219,16 +49329,18 @@ var ts;
return checkDestructuringAssignment(expr, iteratedType || errorType);
}
if (expr.parent.kind === 276) {
- var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent);
- return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent);
+ var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
+ var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType;
+ var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent);
+ return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex);
}
- ts.Debug.assert(expr.parent.kind === 188);
- var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent);
- var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, false, false) || errorType;
- return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType);
+ var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
+ var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
+ var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral, expr.parent, false, false) || errorType;
+ return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
}
function getPropertySymbolOfDestructuringAssignment(location) {
- var typeOfObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(location.parent.parent);
+ var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
}
function getRegularTypeOfExpression(expr) {
@@ -49368,12 +49480,16 @@ var ts;
}
return undefined;
}
+ function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
+ return ts.isBindingElement(symbol.valueDeclaration)
+ && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275;
+ }
function isSymbolOfDeclarationWithCollidingName(symbol) {
if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) {
var links = getSymbolLinks(symbol);
if (links.isDeclarationWithCollidingName === undefined) {
var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
- if (ts.isStatementWithLocals(container)) {
+ if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
if (resolveName(container.parent, symbol.escapedName, 67220415, undefined, undefined, false)) {
links.isDeclarationWithCollidingName = true;
@@ -54485,27 +54601,27 @@ var ts;
function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
if (property === firstAccessor) {
- var properties_6 = [];
+ var properties_5 = [];
if (getAccessor) {
var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body);
ts.setTextRange(getterFunction, getAccessor);
ts.setOriginalNode(getterFunction, getAccessor);
var getter = ts.createPropertyAssignment("get", getterFunction);
- properties_6.push(getter);
+ properties_5.push(getter);
}
if (setAccessor) {
var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body);
ts.setTextRange(setterFunction, setAccessor);
ts.setOriginalNode(setterFunction, setAccessor);
var setter = ts.createPropertyAssignment("set", setterFunction);
- properties_6.push(setter);
+ properties_5.push(setter);
}
- properties_6.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
- properties_6.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
receiver,
createExpressionForPropertyName(property.name),
- ts.createObjectLiteral(properties_6, multiLine)
+ ts.createObjectLiteral(properties_5, multiLine)
]), firstAccessor);
return ts.aggregateTransformFlags(expression);
}
@@ -56055,7 +56171,7 @@ var ts;
}
ts.mergeLexicalEnvironment = mergeLexicalEnvironment;
function liftToBlock(nodes) {
- Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
+ ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
}
ts.liftToBlock = liftToBlock;
@@ -56100,69 +56216,6 @@ var ts;
function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
}
- var Debug;
- (function (Debug) {
- var isDebugInfoEnabled = false;
- function failBadSyntaxKind(node, message) {
- return Debug.fail((message || "Unexpected node.") + "\r\nNode " + ts.formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
- }
- Debug.failBadSyntaxKind = failBadSyntaxKind;
- Debug.assertEachNode = Debug.shouldAssert(1)
- ? function (nodes, test, message) { return Debug.assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertEachNode); }
- : ts.noop;
- Debug.assertNode = Debug.shouldAssert(1)
- ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertNode); }
- : ts.noop;
- Debug.assertOptionalNode = Debug.shouldAssert(1)
- ? function (node, test, message) { return Debug.assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
- : ts.noop;
- Debug.assertOptionalToken = Debug.shouldAssert(1)
- ? function (node, kind, message) { return Debug.assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was not a '" + ts.formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
- : ts.noop;
- Debug.assertMissingNode = Debug.shouldAssert(1)
- ? function (node, message) { return Debug.assert(node === undefined, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
- : ts.noop;
- function enableDebugInfo() {
- if (isDebugInfoEnabled)
- return;
- Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatSymbolFlags(this.flags); } }
- });
- Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } },
- __debugObjectFlags: { get: function () { return this.flags & 524288 ? ts.formatObjectFlags(this.objectFlags) : ""; } },
- __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
- });
- var nodeConstructors = [
- ts.objectAllocator.getNodeConstructor(),
- ts.objectAllocator.getIdentifierConstructor(),
- ts.objectAllocator.getTokenConstructor(),
- ts.objectAllocator.getSourceFileConstructor()
- ];
- for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
- var ctor = nodeConstructors_1[_i];
- if (!ctor.prototype.hasOwnProperty("__debugKind")) {
- Object.defineProperties(ctor.prototype, {
- __debugKind: { get: function () { return ts.formatSyntaxKind(this.kind); } },
- __debugModifierFlags: { get: function () { return ts.formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
- __debugTransformFlags: { get: function () { return ts.formatTransformFlags(this.transformFlags); } },
- __debugEmitFlags: { get: function () { return ts.formatEmitFlags(ts.getEmitFlags(this)); } },
- __debugGetText: {
- value: function (includeTrivia) {
- if (ts.nodeIsSynthesized(this))
- return "";
- var parseNode = ts.getParseTreeNode(this);
- var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
- return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
- }
- }
- });
- }
- }
- isDebugInfoEnabled = true;
- }
- Debug.enableDebugInfo = enableDebugInfo;
- })(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
var ts;
(function (ts) {
@@ -57871,8 +57924,8 @@ var ts;
&& member.initializer !== undefined;
}
function addInitializedPropertyStatements(statements, properties, receiver) {
- for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
- var property = properties_7[_i];
+ for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) {
+ var property = properties_6[_i];
var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver));
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
ts.setCommentRange(statement, property);
@@ -57882,8 +57935,8 @@ var ts;
}
function generateInitializedPropertyExpressions(properties, receiver) {
var expressions = [];
- for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
- var property = properties_8[_i];
+ for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
+ var property = properties_7[_i];
var expression = transformInitializedProperty(property, receiver);
ts.startOnNewLine(expression);
ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
@@ -59611,6 +59664,8 @@ var ts;
return visitObjectLiteralExpression(node);
case 205:
return visitBinaryExpression(node, noDestructuringValue);
+ case 275:
+ return visitCatchClause(node);
case 238:
return visitVariableDeclaration(node);
case 228:
@@ -59736,6 +59791,23 @@ var ts;
}
return ts.visitEachChild(node, visitor, context);
}
+ function visitCatchClause(node) {
+ if (node.variableDeclaration &&
+ ts.isBindingPattern(node.variableDeclaration.name) &&
+ node.variableDeclaration.name.transformFlags & 8192) {
+ var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
+ var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, name);
+ var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1);
+ var block = ts.visitNode(node.block, visitor, ts.isBlock);
+ if (ts.some(visitedBindings)) {
+ block = ts.updateBlock(block, [
+ ts.createVariableStatement(undefined, visitedBindings)
+ ].concat(block.statements));
+ }
+ return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined), block);
+ }
+ return ts.visitEachChild(node, visitor, context);
+ }
function visitVariableDeclaration(node) {
if (ts.isBindingPattern(node.name) && node.name.transformFlags & 8192) {
return ts.flattenDestructuringBinding(node, visitor, context, 1);
@@ -60730,21 +60802,21 @@ var ts;
}
function enterSubtree(excludeFacts, includeFacts) {
var ancestorFacts = hierarchyFacts;
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 8191;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383;
return ancestorFacts;
}
function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -8192 | ancestorFacts;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts;
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
- return (hierarchyFacts & 4096) !== 0
+ return (hierarchyFacts & 8192) !== 0
&& node.kind === 231
&& !node.expression;
}
function shouldVisitNode(node) {
return (node.transformFlags & 128) !== 0
|| convertedLoopState !== undefined
- || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 219)))
+ || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 219)))
|| (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node))
|| (ts.getEmitFlags(node) & 33554432) !== 0;
}
@@ -60861,7 +60933,7 @@ var ts;
}
}
function visitSourceFile(node) {
- var ancestorFacts = enterSubtree(3968, 64);
+ var ancestorFacts = enterSubtree(8064, 64);
var prologue = [];
var statements = [];
startLexicalEnvironment();
@@ -60887,7 +60959,7 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitCaseBlock(node) {
- var ancestorFacts = enterSubtree(4032, 0);
+ var ancestorFacts = enterSubtree(7104, 0);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0, 0);
return updated;
@@ -60914,7 +60986,7 @@ var ts;
}
function visitThisKeyword(node) {
if (hierarchyFacts & 2) {
- hierarchyFacts |= 16384;
+ hierarchyFacts |= 32768;
}
if (convertedLoopState) {
if (hierarchyFacts & 2) {
@@ -61058,7 +61130,7 @@ var ts;
function addConstructor(statements, node, extendsClauseElement) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8086, 73);
+ var ancestorFacts = enterSubtree(16278, 73);
var constructor = ts.getFirstConstructorWithBody(node);
var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getInternalName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
@@ -61067,7 +61139,7 @@ var ts;
ts.setEmitFlags(constructorFunction, 8);
}
statements.push(constructorFunction);
- exitSubtree(ancestorFacts, 24576, 0);
+ exitSubtree(ancestorFacts, 49152, 0);
convertedLoopState = savedConvertedLoopState;
}
function transformConstructorParameters(constructor, hasSynthesizedSuper) {
@@ -61113,7 +61185,7 @@ var ts;
}
}
if (superCallExpression) {
- hierarchyFacts |= 4096;
+ hierarchyFacts |= 8192;
statementOffset++;
}
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset));
@@ -61260,7 +61332,7 @@ var ts;
return true;
}
function insertCaptureThisForNodeIfNeeded(statements, node) {
- if (hierarchyFacts & 16384 && node.kind !== 198) {
+ if (hierarchyFacts & 32768 && node.kind !== 198) {
insertCaptureThisForNode(statements, node, ts.createThis());
return true;
}
@@ -61276,7 +61348,7 @@ var ts;
ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
}
function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
- if (hierarchyFacts & 8192) {
+ if (hierarchyFacts & 16384) {
var newTarget = void 0;
switch (node.kind) {
case 198:
@@ -61392,16 +61464,16 @@ var ts;
}
function visitArrowFunction(node) {
if (node.transformFlags & 2048) {
- hierarchyFacts |= 16384;
+ hierarchyFacts |= 32768;
}
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8064, 66);
+ var ancestorFacts = enterSubtree(15232, 66);
var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
ts.setTextRange(func, node);
ts.setOriginalNode(func, node);
ts.setEmitFlags(func, 8);
- if (hierarchyFacts & 16384) {
+ if (hierarchyFacts & 32768) {
enableSubstitutionsForCapturedThis();
}
exitSubtree(ancestorFacts, 0, 0);
@@ -61410,29 +61482,29 @@ var ts;
}
function visitFunctionExpression(node) {
var ancestorFacts = ts.getEmitFlags(node) & 262144
- ? enterSubtree(8086, 69)
- : enterSubtree(8094, 65);
+ ? enterSubtree(16278, 69)
+ : enterSubtree(16286, 65);
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192
+ var name = hierarchyFacts & 16384
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576, 0);
+ exitSubtree(ancestorFacts, 49152, 0);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body);
}
function visitFunctionDeclaration(node) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094, 65);
+ var ancestorFacts = enterSubtree(16286, 65);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192
+ var name = hierarchyFacts & 16384
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576, 0);
+ exitSubtree(ancestorFacts, 49152, 0);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body);
}
@@ -61440,14 +61512,14 @@ var ts;
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32)
- ? enterSubtree(8094, 65 | 8)
- : enterSubtree(8094, 65);
+ ? enterSubtree(16286, 65 | 8)
+ : enterSubtree(16286, 65);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- if (hierarchyFacts & 8192 && !name && (node.kind === 240 || node.kind === 197)) {
+ if (hierarchyFacts & 16384 && !name && (node.kind === 240 || node.kind === 197)) {
name = ts.getGeneratedNameForNode(node);
}
- exitSubtree(ancestorFacts, 24576, 0);
+ exitSubtree(ancestorFacts, 49152, 0);
convertedLoopState = savedConvertedLoopState;
return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node);
}
@@ -61520,8 +61592,8 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
var ancestorFacts = hierarchyFacts & 256
- ? enterSubtree(4032, 512)
- : enterSubtree(3904, 128);
+ ? enterSubtree(7104, 512)
+ : enterSubtree(6976, 128);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0, 0);
return updated;
@@ -61623,11 +61695,11 @@ var ts;
&& isDeclaredInLoop
&& (hierarchyFacts & 512) !== 0);
var emitExplicitInitializer = !emittedAsTopLevel
- && (hierarchyFacts & 2048) === 0
+ && (hierarchyFacts & 4096) === 0
&& (!resolver.isDeclarationWithCollidingName(node)
|| (isDeclaredInLoop
&& !isCapturedInFunction
- && (hierarchyFacts & (1024 | 2048)) === 0));
+ && (hierarchyFacts & (2048 | 4096)) === 0));
return emitExplicitInitializer;
}
function visitVariableDeclarationInLetDeclarationList(node) {
@@ -61684,21 +61756,21 @@ var ts;
}
function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
- var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert);
+ var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
exitSubtree(ancestorFacts, 0, 0);
return updated;
}
function visitDoOrWhileStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(0, 1280, node, outermostLabeledStatement);
}
function visitForStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(5056, 3328, node, outermostLabeledStatement);
}
function visitForInStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement);
}
function visitForOfStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
+ return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
}
function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
var statements = [];
@@ -61762,7 +61834,7 @@ var ts;
ts.setTextRange(forStatement, node);
return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
}
- function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) {
+ function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined);
@@ -61773,8 +61845,11 @@ var ts;
var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []);
hoistVariableDeclaration(errorRecord);
hoistVariableDeclaration(returnMethod);
+ var initializer = ancestorFacts & 1024
+ ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
+ : values;
var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
- ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, values), node.expression),
+ ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, initializer), node.expression),
ts.createVariableDeclaration(result, undefined, next)
]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), node), 256);
return ts.createTry(ts.createBlock([
@@ -61862,7 +61937,7 @@ var ts;
}
}
}
- function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) {
+ function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
if (!shouldConvertIterationStatement(node)) {
var saveAllowedNonLabeledJumps = void 0;
if (convertedLoopState) {
@@ -61870,7 +61945,7 @@ var ts;
convertedLoopState.allowedNonLabeledJumps = 2 | 4;
}
var result = convert
- ? convert(node, outermostLabeledStatement, undefined)
+ ? convert(node, outermostLabeledStatement, undefined, ancestorFacts)
: ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
if (convertedLoopState) {
convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
@@ -61895,7 +61970,7 @@ var ts;
var loop;
if (bodyFunction) {
if (convert) {
- loop = convert(node, outermostLabeledStatement, bodyFunction.part);
+ loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
}
else {
var clone_3 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, true));
@@ -62251,7 +62326,7 @@ var ts;
return expression;
}
function visitCatchClause(node) {
- var ancestorFacts = enterSubtree(4032, 0);
+ var ancestorFacts = enterSubtree(7104, 0);
var updated;
ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
if (ts.isBindingPattern(node.variableDeclaration.name)) {
@@ -62284,7 +62359,7 @@ var ts;
ts.Debug.assert(!ts.isComputedPropertyName(node.name));
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094, 65);
+ var ancestorFacts = enterSubtree(16286, 65);
var updated;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
@@ -62294,7 +62369,7 @@ var ts;
else {
updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
}
- exitSubtree(ancestorFacts, 24576, 0);
+ exitSubtree(ancestorFacts, 49152, 0);
convertedLoopState = savedConvertedLoopState;
return updated;
}
@@ -62532,14 +62607,14 @@ var ts;
}
function visitMetaProperty(node) {
if (node.keywordToken === 96 && node.name.escapedText === "target") {
- hierarchyFacts |= 8192;
+ hierarchyFacts |= 16384;
return ts.createFileLevelUniqueName("_newTarget");
}
return node;
}
function onEmitNode(hint, node, emitCallback) {
if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) {
- var ancestorFacts = enterSubtree(8094, ts.getEmitFlags(node) & 8
+ var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8
? 65 | 16
: 65);
previousOnEmitNode(hint, node, emitCallback);
@@ -71726,6 +71801,8 @@ var ts;
case 159:
case 160:
return generateNameForMethodOrAccessor(node);
+ case 150:
+ return makeTempVariableName(0, true);
default:
return makeTempVariableName(0);
}
@@ -74057,7 +74134,9 @@ var ts;
if (isRedirect) {
inputName = getProjectReferenceRedirect(fileName) || fileName;
}
- if (ts.getNormalizedAbsolutePath(checkedName, currentDirectory) !== ts.getNormalizedAbsolutePath(inputName, currentDirectory)) {
+ var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
+ var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory);
+ if (checkedAbsolutePath !== inputAbsolutePath) {
reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd);
}
}
@@ -74544,10 +74623,10 @@ var ts;
if (options.module === ts.ModuleKind.None && languageVersion < 2) {
createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
}
- var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6; });
+ var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
@@ -76539,11 +76618,11 @@ var ts;
}
function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
var result = ts.createMap();
- var symlinks = ts.mapDefined(files, function (sf) {
- return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) {
+ var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
+ return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
- });
- });
+ })));
+ }));
for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];
diff --git a/lib/tsserver.js b/lib/tsserver.js
index a36958ec6b226..057eff6e2079d 100644
--- a/lib/tsserver.js
+++ b/lib/tsserver.js
@@ -87,7 +87,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.5";
/** The version of the TypeScript compiler release */
- ts.version = ts.versionMajorMinor + ".0-rc";
+ ts.version = ts.versionMajorMinor + ".1";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@@ -327,7 +327,7 @@ var ts;
ts.firstDefinedIterator = firstDefinedIterator;
function zipWith(arrayA, arrayB, callback) {
var result = [];
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
for (var i = 0; i < arrayA.length; i++) {
result.push(callback(arrayA[i], arrayB[i], i));
}
@@ -335,7 +335,7 @@ var ts;
}
ts.zipWith = zipWith;
function zipToIterator(arrayA, arrayB) {
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
var i = 0;
return {
next: function () {
@@ -349,7 +349,7 @@ var ts;
}
ts.zipToIterator = zipToIterator;
function zipToMap(keys, values) {
- Debug.assert(keys.length === values.length);
+ ts.Debug.assert(keys.length === values.length);
var map = createMap();
for (var i = 0; i < keys.length; ++i) {
map.set(keys[i], values[i]);
@@ -423,7 +423,7 @@ var ts;
return result;
}
}
- return Debug.fail();
+ return ts.Debug.fail();
}
ts.findMap = findMap;
function contains(array, value, equalityComparer) {
@@ -853,7 +853,7 @@ var ts;
continue;
case -1 /* LessThan */:
// If `array` is sorted, `next` should **never** be less than `last`.
- return Debug.fail("Array is unsorted.");
+ return ts.Debug.fail("Array is unsorted.");
}
deduplicated.push(last = next);
}
@@ -920,13 +920,13 @@ var ts;
loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
if (offsetB > 0) {
// Ensure `arrayB` is properly sorted.
- Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
}
loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
if (offsetA > startA) {
// Ensure `arrayA` is properly sorted. We only need to perform this check if
// `offsetA` has changed since we entered the loop.
- Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
}
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
case -1 /* LessThan */:
@@ -1096,7 +1096,7 @@ var ts;
}
ts.firstOrUndefined = firstOrUndefined;
function first(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[0];
}
ts.first = first;
@@ -1108,7 +1108,7 @@ var ts;
}
ts.lastOrUndefined = lastOrUndefined;
function last(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[array.length - 1];
}
ts.last = last;
@@ -1433,7 +1433,7 @@ var ts;
function cast(value, test) {
if (value !== undefined && test(value))
return value;
- return Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + Debug.getFunctionName(test) + "'.");
+ return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
}
ts.cast = cast;
/** Does nothing. */
@@ -1502,92 +1502,6 @@ var ts;
AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive";
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
})(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {}));
- var Debug;
- (function (Debug) {
- Debug.currentAssertionLevel = 0 /* None */;
- Debug.isDebugging = false;
- function shouldAssert(level) {
- return Debug.currentAssertionLevel >= level;
- }
- Debug.shouldAssert = shouldAssert;
- function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
- if (!expression) {
- if (verboseDebugInfo) {
- message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
- }
- fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
- }
- }
- Debug.assert = assert;
- function assertEqual(a, b, msg, msg2) {
- if (a !== b) {
- var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
- fail("Expected " + a + " === " + b + ". " + message);
- }
- }
- Debug.assertEqual = assertEqual;
- function assertLessThan(a, b, msg) {
- if (a >= b) {
- fail("Expected " + a + " < " + b + ". " + (msg || ""));
- }
- }
- Debug.assertLessThan = assertLessThan;
- function assertLessThanOrEqual(a, b) {
- if (a > b) {
- fail("Expected " + a + " <= " + b);
- }
- }
- Debug.assertLessThanOrEqual = assertLessThanOrEqual;
- function assertGreaterThanOrEqual(a, b) {
- if (a < b) {
- fail("Expected " + a + " >= " + b);
- }
- }
- Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
- function fail(message, stackCrawlMark) {
- debugger;
- var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
- if (Error.captureStackTrace) {
- Error.captureStackTrace(e, stackCrawlMark || fail);
- }
- throw e;
- }
- Debug.fail = fail;
- function assertDefined(value, message) {
- if (value === undefined || value === null)
- return fail(message);
- return value;
- }
- Debug.assertDefined = assertDefined;
- function assertEachDefined(value, message) {
- for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
- var v = value_1[_i];
- assertDefined(v, message);
- }
- return value;
- }
- Debug.assertEachDefined = assertEachDefined;
- function assertNever(member, message, stackCrawlMark) {
- if (message === void 0) { message = "Illegal value:"; }
- var detail = typeof member === "object" && "kind" in member && "pos" in member ? "SyntaxKind: " + Debug.showSyntaxKind(member) : JSON.stringify(member);
- return fail(message + " " + detail, stackCrawlMark || assertNever);
- }
- Debug.assertNever = assertNever;
- function getFunctionName(func) {
- if (typeof func !== "function") {
- return "";
- }
- else if (func.hasOwnProperty("name")) {
- return func.name;
- }
- else {
- var text = Function.prototype.toString.call(func);
- var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
- return match ? match[1] : "";
- }
- }
- Debug.getFunctionName = getFunctionName;
- })(Debug = ts.Debug || (ts.Debug = {}));
function equateValues(a, b) {
return a === b;
}
@@ -1844,7 +1758,7 @@ var ts;
bestCandidate = candidate;
}
else {
- Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
+ ts.Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
bestDistance = distance;
bestCandidate = candidate;
}
@@ -1988,7 +1902,7 @@ var ts;
* E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar"
*/
function matchedText(pattern, candidate) {
- Debug.assert(isPatternMatch(pattern, candidate));
+ ts.Debug.assert(isPatternMatch(pattern, candidate));
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
}
ts.matchedText = matchedText;
@@ -2107,6 +2021,242 @@ var ts;
}
}
})(ts || (ts = {}));
+/* @internal */
+var ts;
+(function (ts) {
+ var Debug;
+ (function (Debug) {
+ Debug.currentAssertionLevel = 0 /* None */;
+ Debug.isDebugging = false;
+ function shouldAssert(level) {
+ return Debug.currentAssertionLevel >= level;
+ }
+ Debug.shouldAssert = shouldAssert;
+ function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
+ if (!expression) {
+ if (verboseDebugInfo) {
+ message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
+ }
+ fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
+ }
+ }
+ Debug.assert = assert;
+ function assertEqual(a, b, msg, msg2) {
+ if (a !== b) {
+ var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
+ fail("Expected " + a + " === " + b + ". " + message);
+ }
+ }
+ Debug.assertEqual = assertEqual;
+ function assertLessThan(a, b, msg) {
+ if (a >= b) {
+ fail("Expected " + a + " < " + b + ". " + (msg || ""));
+ }
+ }
+ Debug.assertLessThan = assertLessThan;
+ function assertLessThanOrEqual(a, b) {
+ if (a > b) {
+ fail("Expected " + a + " <= " + b);
+ }
+ }
+ Debug.assertLessThanOrEqual = assertLessThanOrEqual;
+ function assertGreaterThanOrEqual(a, b) {
+ if (a < b) {
+ fail("Expected " + a + " >= " + b);
+ }
+ }
+ Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
+ function fail(message, stackCrawlMark) {
+ debugger;
+ var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(e, stackCrawlMark || fail);
+ }
+ throw e;
+ }
+ Debug.fail = fail;
+ function assertDefined(value, message) {
+ if (value === undefined || value === null)
+ return fail(message);
+ return value;
+ }
+ Debug.assertDefined = assertDefined;
+ function assertEachDefined(value, message) {
+ for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
+ var v = value_1[_i];
+ assertDefined(v, message);
+ }
+ return value;
+ }
+ Debug.assertEachDefined = assertEachDefined;
+ function assertNever(member, message, stackCrawlMark) {
+ if (message === void 0) { message = "Illegal value:"; }
+ var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
+ return fail(message + " " + detail, stackCrawlMark || assertNever);
+ }
+ Debug.assertNever = assertNever;
+ function getFunctionName(func) {
+ if (typeof func !== "function") {
+ return "";
+ }
+ else if (func.hasOwnProperty("name")) {
+ return func.name;
+ }
+ else {
+ var text = Function.prototype.toString.call(func);
+ var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
+ return match ? match[1] : "";
+ }
+ }
+ Debug.getFunctionName = getFunctionName;
+ function formatSymbol(symbol) {
+ return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
+ }
+ Debug.formatSymbol = formatSymbol;
+ /**
+ * Formats an enum value as a string for debugging and debug assertions.
+ */
+ function formatEnum(value, enumObject, isFlags) {
+ if (value === void 0) { value = 0; }
+ var members = getEnumMembers(enumObject);
+ if (value === 0) {
+ return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
+ }
+ if (isFlags) {
+ var result = "";
+ var remainingFlags = value;
+ for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
+ var _a = members[i], enumValue = _a[0], enumName = _a[1];
+ if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
+ remainingFlags &= ~enumValue;
+ result = "" + enumName + (result ? "|" : "") + result;
+ }
+ }
+ if (remainingFlags === 0) {
+ return result;
+ }
+ }
+ else {
+ for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
+ var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
+ if (enumValue === value) {
+ return enumName;
+ }
+ }
+ }
+ return value.toString();
+ }
+ Debug.formatEnum = formatEnum;
+ function getEnumMembers(enumObject) {
+ var result = [];
+ for (var name in enumObject) {
+ var value = enumObject[name];
+ if (typeof value === "number") {
+ result.push([value, name]);
+ }
+ }
+ return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
+ }
+ function formatSyntaxKind(kind) {
+ return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
+ }
+ Debug.formatSyntaxKind = formatSyntaxKind;
+ function formatNodeFlags(flags) {
+ return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
+ }
+ Debug.formatNodeFlags = formatNodeFlags;
+ function formatModifierFlags(flags) {
+ return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
+ }
+ Debug.formatModifierFlags = formatModifierFlags;
+ function formatTransformFlags(flags) {
+ return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
+ }
+ Debug.formatTransformFlags = formatTransformFlags;
+ function formatEmitFlags(flags) {
+ return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
+ }
+ Debug.formatEmitFlags = formatEmitFlags;
+ function formatSymbolFlags(flags) {
+ return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
+ }
+ Debug.formatSymbolFlags = formatSymbolFlags;
+ function formatTypeFlags(flags) {
+ return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
+ }
+ Debug.formatTypeFlags = formatTypeFlags;
+ function formatObjectFlags(flags) {
+ return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
+ }
+ Debug.formatObjectFlags = formatObjectFlags;
+ function failBadSyntaxKind(node, message) {
+ return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
+ }
+ Debug.failBadSyntaxKind = failBadSyntaxKind;
+ Debug.assertEachNode = shouldAssert(1 /* Normal */)
+ ? function (nodes, test, message) { return assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertEachNode); }
+ : ts.noop;
+ Debug.assertNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); }
+ : ts.noop;
+ Debug.assertOptionalNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
+ : ts.noop;
+ Debug.assertOptionalToken = shouldAssert(1 /* Normal */)
+ ? function (node, kind, message) { return assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
+ : ts.noop;
+ Debug.assertMissingNode = shouldAssert(1 /* Normal */)
+ ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
+ : ts.noop;
+ var isDebugInfoEnabled = false;
+ /**
+ * Injects debug information into frequently used types.
+ */
+ function enableDebugInfo() {
+ if (isDebugInfoEnabled)
+ return;
+ // Add additional properties in debug mode to assist with debugging.
+ Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
+ __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
+ });
+ Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
+ __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
+ __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } },
+ __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
+ });
+ var nodeConstructors = [
+ ts.objectAllocator.getNodeConstructor(),
+ ts.objectAllocator.getIdentifierConstructor(),
+ ts.objectAllocator.getTokenConstructor(),
+ ts.objectAllocator.getSourceFileConstructor()
+ ];
+ for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
+ var ctor = nodeConstructors_1[_i];
+ if (!ctor.prototype.hasOwnProperty("__debugKind")) {
+ Object.defineProperties(ctor.prototype, {
+ __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
+ __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
+ __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
+ __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
+ __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
+ __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
+ __debugGetText: {
+ value: function (includeTrivia) {
+ if (ts.nodeIsSynthesized(this))
+ return "";
+ var parseNode = ts.getParseTreeNode(this);
+ var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
+ return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
+ }
+ }
+ });
+ }
+ }
+ isDebugInfoEnabled = true;
+ }
+ Debug.enableDebugInfo = enableDebugInfo;
+ })(Debug = ts.Debug || (ts.Debug = {}));
+})(ts || (ts = {}));
/*@internal*/
var ts;
(function (ts) {
@@ -5335,7 +5485,7 @@ var ts;
Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."),
Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
- Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", "Cannot compile namespaces when the '--isolatedModules' flag is provided."),
+ All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."),
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."),
A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
@@ -6122,7 +6272,6 @@ var ts;
Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."),
Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
Multiple_consecutive_numeric_separators_are_not_permitted: diag(6189, ts.DiagnosticCategory.Error, "Multiple_consecutive_numeric_separators_are_not_permitted_6189", "Multiple consecutive numeric separators are not permitted."),
- Found_package_json_at_0_Package_ID_is_1: diag(6190, ts.DiagnosticCategory.Message, "Found_package_json_at_0_Package_ID_is_1_6190", "Found 'package.json' at '{0}'. Package ID is '{1}'."),
Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: diag(6191, ts.DiagnosticCategory.Message, "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191", "Whether to keep outdated console output in watch mode instead of clearing the screen."),
All_imports_in_import_declaration_are_unused: diag(6192, ts.DiagnosticCategory.Error, "All_imports_in_import_declaration_are_unused_6192", "All imports in import declaration are unused.", /*reportsUnnecessary*/ true),
Found_1_error_Watching_for_file_changes: diag(6193, ts.DiagnosticCategory.Message, "Found_1_error_Watching_for_file_changes_6193", "Found 1 error. Watching for file changes."),
@@ -6149,6 +6298,9 @@ var ts;
Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."),
Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
+ Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"),
+ Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"),
+ package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."),
Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
@@ -6238,6 +6390,8 @@ var ts;
_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."),
Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1: diag(7051, ts.DiagnosticCategory.Error, "Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1_7051", "Parameter has a name but no type. Did you mean '{0}: {1}'?"),
Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1: diag(7052, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1_7052", "Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}' ?"),
+ Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: diag(7053, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053", "Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'."),
+ No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1: diag(7054, ts.DiagnosticCategory.Error, "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054", "No index signature with a parameter of type '{0}' was found on type '{1}'."),
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."),
@@ -10311,7 +10465,7 @@ var ts;
}
ts.isFunctionSymbol = isFunctionSymbol;
function importFromModuleSpecifier(node) {
- return tryGetImportFromModuleSpecifier(node) || ts.Debug.fail(ts.Debug.showSyntaxKind(node.parent));
+ return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
}
ts.importFromModuleSpecifier = importFromModuleSpecifier;
function tryGetImportFromModuleSpecifier(node) {
@@ -12266,77 +12420,6 @@ var ts;
return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
- /**
- * Formats an enum value as a string for debugging and debug assertions.
- */
- function formatEnum(value, enumObject, isFlags) {
- if (value === void 0) { value = 0; }
- var members = getEnumMembers(enumObject);
- if (value === 0) {
- return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
- }
- if (isFlags) {
- var result = "";
- var remainingFlags = value;
- for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
- var _a = members[i], enumValue = _a[0], enumName = _a[1];
- if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
- remainingFlags &= ~enumValue;
- result = "" + enumName + (result ? ", " : "") + result;
- }
- }
- if (remainingFlags === 0) {
- return result;
- }
- }
- else {
- for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
- var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
- if (enumValue === value) {
- return enumName;
- }
- }
- }
- return value.toString();
- }
- function getEnumMembers(enumObject) {
- var result = [];
- for (var name in enumObject) {
- var value = enumObject[name];
- if (typeof value === "number") {
- result.push([value, name]);
- }
- }
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
- }
- function formatSyntaxKind(kind) {
- return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
- }
- ts.formatSyntaxKind = formatSyntaxKind;
- function formatModifierFlags(flags) {
- return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
- }
- ts.formatModifierFlags = formatModifierFlags;
- function formatTransformFlags(flags) {
- return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
- }
- ts.formatTransformFlags = formatTransformFlags;
- function formatEmitFlags(flags) {
- return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
- }
- ts.formatEmitFlags = formatEmitFlags;
- function formatSymbolFlags(flags) {
- return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
- }
- ts.formatSymbolFlags = formatSymbolFlags;
- function formatTypeFlags(flags) {
- return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
- }
- ts.formatTypeFlags = formatTypeFlags;
- function formatObjectFlags(flags) {
- return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
- }
- ts.formatObjectFlags = formatObjectFlags;
/**
* Creates a new TextRange from the provided pos and end.
*
@@ -15530,6 +15613,15 @@ var ts;
return root + pathComponents.slice(1).join(ts.directorySeparator);
}
ts.getPathFromPathComponents = getPathFromPathComponents;
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
+ }
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
+ function getPathWithoutRoot(pathComponents) {
+ if (pathComponents.length === 0)
+ return "";
+ return pathComponents.slice(1).join(ts.directorySeparator);
+ }
})(ts || (ts = {}));
/* @internal */
(function (ts) {
@@ -15560,7 +15652,7 @@ var ts;
}
ts.getRelativePathFromFile = getRelativePathFromFile;
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
- Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
+ ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
@@ -16204,32 +16296,9 @@ var ts;
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
}
ts.changeAnyExtension = changeAnyExtension;
- var Debug;
- (function (Debug) {
- function showSymbol(symbol) {
- var symbolFlags = ts.SymbolFlags;
- return "{ flags: " + (symbolFlags ? showFlags(symbol.flags, symbolFlags) : symbol.flags) + "; declarations: " + ts.map(symbol.declarations, showSyntaxKind) + " }";
- }
- Debug.showSymbol = showSymbol;
- function showFlags(flags, flagsEnum) {
- var out = [];
- for (var pow = 0; pow <= 30; pow++) {
- var n = 1 << pow;
- if (flags & n) {
- out.push(flagsEnum[n]);
- }
- }
- return out.join("|");
- }
- function showSyntaxKind(node) {
- var syntaxKind = ts.SyntaxKind;
- return syntaxKind ? syntaxKind[node.kind] : node.kind.toString();
- }
- Debug.showSyntaxKind = showSyntaxKind;
- })(Debug = ts.Debug || (ts.Debug = {}));
function tryParsePattern(pattern) {
// This should be verified outside of here and a proper error thrown.
- Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
+ ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
var indexOfStar = pattern.indexOf("*");
return indexOfStar === -1 ? undefined : {
prefix: pattern.substr(0, indexOfStar),
@@ -16258,7 +16327,7 @@ var ts;
*/
function extensionFromPath(path) {
var ext = tryGetExtensionFromPath(path);
- return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension.");
+ return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
}
ts.extensionFromPath = extensionFromPath;
function isAnySupportedFileExtension(path) {
@@ -16330,7 +16399,7 @@ var ts;
ts.matchPatternOrExact = matchPatternOrExact;
function sliceAfter(arr, value) {
var index = arr.indexOf(value);
- Debug.assert(index !== -1);
+ ts.Debug.assert(index !== -1);
return arr.slice(index);
}
ts.sliceAfter = sliceAfter;
@@ -16348,7 +16417,7 @@ var ts;
}
ts.addRelatedInfo = addRelatedInfo;
function minAndMax(arr, getValue) {
- Debug.assert(arr.length !== 0);
+ ts.Debug.assert(arr.length !== 0);
var min = getValue(arr[0]);
var max = min;
for (var i = 1; i < arr.length; i++) {
@@ -25744,7 +25813,7 @@ var ts;
if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) {
extendedConfigPath = extendedConfigPath + ".json";
if (!host.fileExists(extendedConfigPath)) {
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
}
@@ -25755,7 +25824,7 @@ var ts;
if (resolved.resolvedModule) {
return resolved.resolvedModule.resolvedFileName;
}
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
@@ -26270,11 +26339,22 @@ var ts;
return !!compilerOptions.traceResolution && host.trace !== undefined;
}
ts.isTraceEnabled = isTraceEnabled;
- function withPackageId(packageId, r) {
+ function withPackageId(packageInfo, r) {
+ var packageId;
+ if (r && packageInfo) {
+ var packageJsonContent = packageInfo.packageJsonContent;
+ if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
+ packageId = {
+ name: packageJsonContent.name,
+ subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
+ version: packageJsonContent.version
+ };
+ }
+ }
return r && { path: r.path, extension: r.ext, packageId: packageId };
}
function noPackageId(r) {
- return withPackageId(/*packageId*/ undefined, r);
+ return withPackageId(/*packageInfo*/ undefined, r);
}
function removeIgnoredPackageId(r) {
if (r) {
@@ -26326,8 +26406,15 @@ var ts;
}
function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
- if (fileName === undefined)
+ if (fileName === undefined) {
+ return;
+ }
+ if (!fileName) {
+ if (state.traceEnabled) {
+ trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
+ }
return;
+ }
var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
@@ -26480,7 +26567,12 @@ var ts;
var fileName = resolved.fileName, packageId = resolved.packageId;
var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
if (traceEnabled) {
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ if (packageId) {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary);
+ }
+ else {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ }
}
resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
}
@@ -26768,7 +26860,12 @@ var ts;
}
if (traceEnabled) {
if (result.resolvedModule) {
- trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ if (result.resolvedModule.packageId) {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2, moduleName, result.resolvedModule.resolvedFileName, ts.packageIdToString(result.resolvedModule.packageId));
+ }
+ else {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ }
}
else {
trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
@@ -27038,10 +27135,9 @@ var ts;
}
var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
if (resolvedFromFile) {
- var nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
- var packageInfo = nm && getPackageJsonInfo(nm.packageDirectory, nm.subModuleName, /*onlyRecordFailures*/ false, state);
- var packageId = packageInfo && packageInfo.packageId;
- return withPackageId(packageId, resolvedFromFile);
+ var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
+ var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined;
+ return withPackageId(packageInfo, resolvedFromFile);
}
}
if (!onlyRecordFailures) {
@@ -27067,11 +27163,10 @@ var ts;
* (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.)
*
* packageDirectory is the directory of the package itself.
- * subModuleName is the path within the package.
- * For `blah/node_modules/foo/index.d.ts` this is { packageDirectory: "foo", subModuleName: "index.d.ts" }. (Part before "/node_modules/" is ignored.)
- * For `/node_modules/foo/bar.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
- * For `/node_modules/@types/foo/bar/index.d.ts` this is { packageDirectory: "@types/foo", subModuleName: "bar/index.d.ts" }.
- * For `/node_modules/foo/bar/index.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
+ * For `blah/node_modules/foo/index.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/foo/bar.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo"
+ * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo"
*/
function parseNodeModuleFromPath(resolved) {
var path = ts.normalizePath(resolved.path);
@@ -27084,26 +27179,12 @@ var ts;
if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) {
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
}
- var packageDirectory = path.slice(0, indexAfterPackageName);
- var subModuleName = ts.removeExtension(path.slice(indexAfterPackageName + 1), resolved.ext) + ".d.ts" /* Dts */;
- return { packageDirectory: packageDirectory, subModuleName: subModuleName };
+ return path.slice(0, indexAfterPackageName);
}
function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
}
- function addExtensionAndIndex(path) {
- if (path === "") {
- return "index.d.ts";
- }
- if (ts.endsWith(path, ".d.ts")) {
- return path;
- }
- if (path === "index" || ts.endsWith(path, "/index")) {
- return path + ".d.ts";
- }
- return path + "/index.d.ts";
- }
function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
}
@@ -27177,52 +27258,22 @@ var ts;
}
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
if (considerPackageJson === void 0) { considerPackageJson = true; }
- var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, "", onlyRecordFailures, state) : undefined;
- var packageId = packageInfo && packageInfo.packageId;
+ var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
var versionPaths = packageInfo && packageInfo.versionPaths;
- return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
+ return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
}
- function getPackageJsonInfo(packageDirectory, subModuleName, onlyRecordFailures, state) {
+ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
var host = state.host, traceEnabled = state.traceEnabled;
var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
if (directoryExists && host.fileExists(packageJsonPath)) {
var packageJsonContent = ts.readJson(packageJsonPath, host);
- if (subModuleName === "") { // looking up the root - need to handle types/typings/main redirects for subModuleName
- var path = readPackageJsonTypesFields(packageJsonContent, packageDirectory, state);
- if (typeof path === "string") {
- subModuleName = addExtensionAndIndex(path.substring(packageDirectory.length + 1));
- }
- else {
- var jsPath = readPackageJsonMainField(packageJsonContent, packageDirectory, state);
- if (typeof jsPath === "string" && jsPath.length > packageDirectory.length) {
- var potentialSubModule_1 = jsPath.substring(packageDirectory.length + 1);
- subModuleName = (ts.forEach(ts.supportedJSExtensions, function (extension) {
- return ts.tryRemoveExtension(potentialSubModule_1, extension);
- }) || potentialSubModule_1) + ".d.ts" /* Dts */;
- }
- else {
- subModuleName = "index.d.ts";
- }
- }
- }
- if (!ts.endsWith(subModuleName, ".d.ts" /* Dts */)) {
- subModuleName = addExtensionAndIndex(subModuleName);
- }
- var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
- var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string"
- ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version }
- : undefined;
if (traceEnabled) {
- if (packageId) {
- trace(host, ts.Diagnostics.Found_package_json_at_0_Package_ID_is_1, packageJsonPath, ts.packageIdToString(packageId));
- }
- else {
- trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
- }
+ trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
}
- return { packageJsonContent: packageJsonContent, packageId: packageId, versionPaths: versionPaths };
+ var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
+ return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
}
else {
if (directoryExists && traceEnabled) {
@@ -27361,37 +27412,31 @@ var ts;
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
- var packageJsonContent;
- var packageId;
- var versionPaths;
- var packageInfo = getPackageJsonInfo(candidate, "", !nodeModulesDirectoryExists, state);
+ var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
if (packageInfo) {
- (packageJsonContent = packageInfo.packageJsonContent, packageId = packageInfo.packageId, versionPaths = packageInfo.versionPaths);
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
if (fromFile) {
return noPackageId(fromFile);
}
- var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, fromDirectory);
+ var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
+ return withPackageId(packageInfo, fromDirectory);
}
var loader = function (extensions, candidate, onlyRecordFailures, state) {
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
- loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, pathAndExtension);
+ loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
+ return withPackageId(packageInfo, pathAndExtension);
};
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
if (rest !== "") { // If "rest" is empty, we just did this search above.
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
// Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings.
- var packageInfo_1 = getPackageJsonInfo(packageDirectory, rest, !nodeModulesDirectoryExists, state);
- if (packageInfo_1)
- (packageId = packageInfo_1.packageId, versionPaths = packageInfo_1.versionPaths);
- if (versionPaths) {
+ packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
+ if (packageInfo && packageInfo.versionPaths) {
if (state.traceEnabled) {
- trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, rest);
+ trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest);
}
var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, versionPaths.paths, loader, !packageDirectoryExists, state);
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
if (fromPaths) {
return fromPaths.value;
}
@@ -29846,7 +29891,7 @@ var ts;
}
break;
default:
- ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer));
+ ts.Debug.failBadSyntaxKind(thisContainer);
}
}
function bindSpecialPropertyDeclaration(node) {
@@ -29904,7 +29949,7 @@ var ts;
// Fix up parent pointers since we're going to use these nodes before we bind into them
node.left.parent = node;
node.right.parent = node;
- if (ts.isIdentifier(lhs.expression) && container === file && isNameOfExportsOrModuleExportsAliasDeclaration(file, lhs.expression)) {
+ if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) {
// This can be an alias for the 'exports' or 'module.exports' names, e.g.
// var util = module.exports;
// util.property = function ...
@@ -30259,20 +30304,29 @@ var ts;
}
}
function isExportsOrModuleExportsOrAlias(sourceFile, node) {
- return ts.isExportsIdentifier(node) ||
- ts.isModuleExportsPropertyAccessExpression(node) ||
- ts.isIdentifier(node) && isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node);
+ var i = 0;
+ var q = [node];
+ while (q.length && i < 100) {
+ i++;
+ node = q.shift();
+ if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) {
+ return true;
+ }
+ else if (ts.isIdentifier(node)) {
+ var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
+ if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
+ var init = symbol.valueDeclaration.initializer;
+ q.push(init);
+ if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) {
+ q.push(init.left);
+ q.push(init.right);
+ }
+ }
+ }
+ }
+ return false;
}
ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
- function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) {
- var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
- return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) &&
- !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer);
- }
- function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) {
- return isExportsOrModuleExportsOrAlias(sourceFile, node) ||
- (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && (isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.left) || isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.right)));
- }
function lookupSymbolForNameWorker(container, name) {
var local = container.locals && container.locals.get(name);
if (local) {
@@ -31412,6 +31466,10 @@ var ts;
node = ts.getParseTreeNode(node);
return node ? getTypeOfNode(node) : errorType;
},
+ getTypeOfAssignmentPattern: function (nodeIn) {
+ var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
+ return node && getTypeOfAssignmentPattern(node) || errorType;
+ },
getPropertySymbolOfDestructuringAssignment: function (locationIn) {
var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
@@ -34512,7 +34570,7 @@ var ts;
context.approximateLength += 6;
return ts.createKeywordTypeNode(137 /* ObjectKeyword */);
}
- if (type.flags & 262144 /* TypeParameter */ && type.isThisType) {
+ if (isThisTypeParameter(type)) {
if (context.flags & 4194304 /* InObjectTypeLiteral */) {
if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
context.encounteredError = true;
@@ -35202,6 +35260,11 @@ var ts;
function lookupTypeParameterNodes(chain, index, context) {
ts.Debug.assert(chain && 0 <= index && index < chain.length);
var symbol = chain[index];
+ var symbolId = "" + getSymbolId(symbol);
+ if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
+ return undefined;
+ }
+ (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
var typeParameterNodes;
if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) {
var parentSymbol = symbol;
@@ -36142,7 +36205,7 @@ var ts;
return type;
}
else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(declaredType, declaration, type);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
}
}
return declaredType;
@@ -36461,7 +36524,7 @@ var ts;
type = getTypeOfEnumMember(symbol);
}
else {
- return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol));
+ return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
}
if (!popTypeResolution()) {
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
@@ -37731,10 +37794,10 @@ var ts;
// Union the result types when more than one signature matches
if (unionSignatures.length > 1) {
var thisParameter = signature.thisParameter;
- if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) {
- // TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do
+ var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
+ if (firstThisParameterOfUnionSignatures) {
var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */);
- thisParameter = createSymbolWithType(signature.thisParameter, thisType);
+ thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
}
s = createUnionSignature(signature, unionSignatures);
s.thisParameter = thisParameter;
@@ -38300,15 +38363,19 @@ var ts;
function getConstraintOfIndexedAccess(type) {
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
}
+ function getSimplifiedTypeOrConstraint(type) {
+ var simplified = getSimplifiedType(type, /*writing*/ false);
+ return simplified !== type ? simplified : getConstraintOfType(type);
+ }
function getConstraintFromIndexedAccess(type) {
- var indexConstraint = getConstraintOfType(type.indexType);
+ var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
if (indexConstraint && indexConstraint !== type.indexType) {
var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
if (indexedAccess) {
return indexedAccess;
}
}
- var objectConstraint = getConstraintOfType(type.objectType);
+ var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
if (objectConstraint && objectConstraint !== type.objectType) {
return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
}
@@ -40297,6 +40364,14 @@ var ts;
types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
return true;
}
+ function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
+ var result = createType(2097152 /* Intersection */);
+ result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
+ result.types = types;
+ result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
+ result.aliasTypeArguments = aliasTypeArguments;
+ return result;
+ }
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
@@ -40334,30 +40409,36 @@ var ts;
if (typeSet.length === 1) {
return typeSet[0];
}
- if (includes & 1048576 /* Union */) {
- if (intersectUnionsOfPrimitiveTypes(typeSet)) {
- // When the intersection creates a reduced set (which might mean that *all* union types have
- // disappeared), we restart the operation to get a new set of combined flags. Once we have
- // reduced we'll never reduce again, so this occurs at most once.
- return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
- }
- // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
- // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
- var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
- var unionType = typeSet[unionIndex_1];
- return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
- }
var id = getTypeListId(typeSet);
- var type = intersectionTypes.get(id);
- if (!type) {
- type = createType(2097152 /* Intersection */);
- intersectionTypes.set(id, type);
- type.objectFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */);
- type.types = typeSet;
- type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
- type.aliasTypeArguments = aliasTypeArguments;
+ var result = intersectionTypes.get(id);
+ if (!result) {
+ if (includes & 1048576 /* Union */) {
+ if (intersectUnionsOfPrimitiveTypes(typeSet)) {
+ // When the intersection creates a reduced set (which might mean that *all* union types have
+ // disappeared), we restart the operation to get a new set of combined flags. Once we have
+ // reduced we'll never reduce again, so this occurs at most once.
+ result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ else {
+ // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
+ // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
+ // If the estimated size of the resulting union type exceeds 100000 constituents, report an error.
+ var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 /* Union */ ? t.types.length : 1); }, 1);
+ if (size >= 100000) {
+ error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
+ return errorType;
+ }
+ var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
+ var unionType = typeSet[unionIndex_1];
+ result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
+ }
+ }
+ else {
+ result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ intersectionTypes.set(id, result);
}
- return type;
+ return result;
}
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
@@ -40490,7 +40571,7 @@ var ts;
}
return false;
}
- function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, accessNode, accessFlags) {
+ function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined;
var propName = isTypeUsableAsPropertyName(indexType) ?
getPropertyNameFromType(indexType) :
@@ -40528,6 +40609,7 @@ var ts;
error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
}
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */));
return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
}
}
@@ -40549,13 +40631,7 @@ var ts;
error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
return indexInfo.type;
}
- if (indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
- if (accessExpression) {
- error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
- return indexInfo.type;
- }
- return undefined;
- }
+ errorIfWritingToReadonlyIndex(indexInfo);
return indexInfo.type;
}
if (indexType.flags & 131072 /* Never */) {
@@ -40568,7 +40644,7 @@ var ts;
if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) {
error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
- else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
+ else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
}
@@ -40588,7 +40664,25 @@ var ts;
error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion_1);
}
else {
- error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType));
+ var errorInfo = void 0;
+ if (indexType.flags & 1024 /* EnumLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 8192 /* UniqueESSymbol */) {
+ var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 128 /* StringLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & 256 /* NumberLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
+ }
+ errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType));
+ diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
}
}
}
@@ -40615,6 +40709,11 @@ var ts;
return indexType;
}
return undefined;
+ function errorIfWritingToReadonlyIndex(indexInfo) {
+ if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
+ error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
+ }
+ }
}
function getIndexNodeForAccessExpression(accessNode) {
return accessNode.kind === 191 /* ElementAccessExpression */
@@ -40631,6 +40730,9 @@ var ts;
function isGenericIndexType(type) {
return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */);
}
+ function isThisTypeParameter(type) {
+ return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
+ }
function getSimplifiedType(type, writing) {
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
@@ -40766,7 +40868,7 @@ var ts;
var wasMissingProp = false;
for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
var t = _a[_i];
- var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, accessNode, accessFlags);
+ var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
if (propType) {
propTypes.push(propType);
}
@@ -40784,7 +40886,7 @@ var ts;
}
return accessFlags & 2 /* Writing */ ? getIntersectionType(propTypes) : getUnionType(propTypes);
}
- return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, accessNode, accessFlags | 4 /* CacheSymbol */);
+ return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */);
}
function getTypeFromIndexedAccessTypeNode(node) {
var links = getNodeLinks(node);
@@ -43330,8 +43432,7 @@ var ts;
}
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
// simplified form of T or, if T doesn't simplify, the constraint of T.
- var simplified = getSimplifiedType(target.type, /*writing*/ false);
- var constraint = simplified !== target.type ? simplified : getConstraintOfType(target.type);
+ var constraint = getSimplifiedTypeOrConstraint(target.type);
if (constraint) {
// We require Ternary.True here such that circular constraints don't cause
// false positives. For example, given 'T extends { [K in keyof T]: string }',
@@ -46872,7 +46973,7 @@ var ts;
return !assumeTrue;
}
function narrowByInKeyword(type, literal, assumeTrue) {
- if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) {
+ if (type.flags & (1048576 /* Union */ | 524288 /* Object */) || isThisTypeParameter(type)) {
var propName_1 = ts.escapeLeadingUnderscores(literal.text);
return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
}
@@ -48424,8 +48525,8 @@ var ts;
// For a (non-symbol) computed property, there is no reason to look up the name
// in the type. It will just be "__computed", which does not appear in any
// SymbolTable.
- var symbolName_2 = getSymbolOfNode(element).escapedName;
- var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_2);
+ var symbolName_3 = getSymbolOfNode(element).escapedName;
+ var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
if (propertyType) {
return propertyType;
}
@@ -49900,7 +50001,7 @@ var ts;
return anyType;
}
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
- reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType);
+ reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
}
return errorType;
}
@@ -50265,7 +50366,7 @@ var ts;
}
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
var accessFlags = ts.isAssignmentTarget(node) ?
- 2 /* Writing */ | (isGenericObjectType(objectType) ? 1 /* NoIndexSignatures */ : 0) :
+ 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) :
0 /* None */;
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
return checkIndexedAccessIndexType(indexedAccessType, node);
@@ -52845,15 +52946,16 @@ var ts;
if (strictNullChecks && properties.length === 0) {
return checkNonNullType(sourceType, node);
}
- for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
- var p = properties_4[_i];
- checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis);
+ for (var i = 0; i < properties.length; i++) {
+ checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
}
return sourceType;
}
/** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */
- function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) {
+ function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
if (rightIsThis === void 0) { rightIsThis = false; }
+ var properties = node.properties;
+ var property = properties[propertyIndex];
if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) {
var name = property.name;
var exprType = getLiteralTypeFromPropertyName(name);
@@ -52870,18 +52972,26 @@ var ts;
return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
}
else if (property.kind === 278 /* SpreadAssignment */) {
- if (languageVersion < 8 /* ESNext */) {
- checkExternalEmitHelpers(property, 4 /* Rest */);
+ if (propertyIndex < properties.length - 1) {
+ error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
}
- var nonRestNames = [];
- if (allProperties) {
- for (var i = 0; i < allProperties.length - 1; i++) {
- nonRestNames.push(allProperties[i].name);
+ else {
+ if (languageVersion < 8 /* ESNext */) {
+ checkExternalEmitHelpers(property, 4 /* Rest */);
+ }
+ var nonRestNames = [];
+ if (allProperties) {
+ for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
+ var otherProperty = allProperties_1[_i];
+ if (!ts.isSpreadAssignment(otherProperty)) {
+ nonRestNames.push(otherProperty.name);
+ }
+ }
}
+ var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
+ checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
+ return checkDestructuringAssignment(property.expression, type);
}
- var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
- checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
- return checkDestructuringAssignment(property.expression, type);
}
else {
error(property, ts.Diagnostics.Property_assignment_expected);
@@ -54820,7 +54930,7 @@ var ts;
case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591
return 1 /* ExportValue */;
default:
- return ts.Debug.fail(ts.Debug.showSyntaxKind(d));
+ return ts.Debug.failBadSyntaxKind(d);
}
}
}
@@ -55985,7 +56095,7 @@ var ts;
if (type !== errorType && declarationType !== errorType &&
!isTypeIdenticalTo(type, declarationType) &&
!(symbol.flags & 67108864 /* Assignment */)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
}
if (node.initializer) {
checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined);
@@ -56004,12 +56114,16 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) {
+ function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */
? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
: ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
- error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType));
+ var declName = ts.declarationNameToString(nextDeclarationName);
+ var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
+ if (firstDeclaration) {
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
+ }
}
function areDeclarationFlagsIdentical(left, right) {
if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) ||
@@ -57150,8 +57264,8 @@ var ts;
for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
var base = baseTypes_2[_i];
var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
- for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) {
- var prop = properties_5[_a];
+ for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) {
+ var prop = properties_4[_a];
var existing = seen.get(prop.escapedName);
if (!existing) {
seen.set(prop.escapedName, { prop: prop, containingType: base });
@@ -58767,7 +58881,7 @@ var ts;
// }
// [ a ] from
// [a] = [ some array ...]
- function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) {
+ function getTypeOfAssignmentPattern(expr) {
ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */);
// If this is from "for of"
// for ( { a } of elems) {
@@ -58785,15 +58899,17 @@ var ts;
// If this is from nested object binding pattern
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
if (expr.parent.kind === 276 /* PropertyAssignment */) {
- var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent);
- return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217
+ var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
+ var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType;
+ var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent);
+ return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex);
}
// Array literal assignment - array destructuring pattern
- ts.Debug.assert(expr.parent.kind === 188 /* ArrayLiteralExpression */);
+ var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
// [{ property1: p1, property2 }] = elems;
- var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent);
- var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
- return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); // TODO: GH#18217
+ var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
+ var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
+ return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
}
// Gets the property symbol corresponding to the property in destructuring assignment
// 'property1' from
@@ -58803,7 +58919,7 @@ var ts;
// [a] = [ property1, property2 ]
function getPropertySymbolOfDestructuringAssignment(location) {
// Get the type of the object or array literal and then look for property of given name in the type
- var typeOfObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(location.parent.parent);
+ var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
}
function getRegularTypeOfExpression(expr) {
@@ -58969,12 +59085,16 @@ var ts;
}
return undefined;
}
+ function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
+ return ts.isBindingElement(symbol.valueDeclaration)
+ && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */;
+ }
function isSymbolOfDeclarationWithCollidingName(symbol) {
if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) {
var links = getSymbolLinks(symbol);
if (links.isDeclarationWithCollidingName === undefined) {
var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
- if (ts.isStatementWithLocals(container)) {
+ if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) {
// redeclaration - always should be renamed
@@ -64457,7 +64577,7 @@ var ts;
function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
if (property === firstAccessor) {
- var properties_6 = [];
+ var properties_5 = [];
if (getAccessor) {
var getterFunction = ts.createFunctionExpression(getAccessor.modifiers,
/*asteriskToken*/ undefined,
@@ -64468,7 +64588,7 @@ var ts;
ts.setTextRange(getterFunction, getAccessor);
ts.setOriginalNode(getterFunction, getAccessor);
var getter = ts.createPropertyAssignment("get", getterFunction);
- properties_6.push(getter);
+ properties_5.push(getter);
}
if (setAccessor) {
var setterFunction = ts.createFunctionExpression(setAccessor.modifiers,
@@ -64480,15 +64600,15 @@ var ts;
ts.setTextRange(setterFunction, setAccessor);
ts.setOriginalNode(setterFunction, setAccessor);
var setter = ts.createPropertyAssignment("set", setterFunction);
- properties_6.push(setter);
+ properties_5.push(setter);
}
- properties_6.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
- properties_6.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"),
/*typeArguments*/ undefined, [
receiver,
createExpressionForPropertyName(property.name),
- ts.createObjectLiteral(properties_6, multiLine)
+ ts.createObjectLiteral(properties_5, multiLine)
]),
/*location*/ firstAccessor);
return ts.aggregateTransformFlags(expression);
@@ -66467,7 +66587,7 @@ var ts;
* @param nodes The NodeArray.
*/
function liftToBlock(nodes) {
- Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
+ ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
}
ts.liftToBlock = liftToBlock;
@@ -66532,73 +66652,6 @@ var ts;
function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
}
- var Debug;
- (function (Debug) {
- var isDebugInfoEnabled = false;
- function failBadSyntaxKind(node, message) {
- return Debug.fail((message || "Unexpected node.") + "\r\nNode " + ts.formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
- }
- Debug.failBadSyntaxKind = failBadSyntaxKind;
- Debug.assertEachNode = Debug.shouldAssert(1 /* Normal */)
- ? function (nodes, test, message) { return Debug.assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertEachNode); }
- : ts.noop;
- Debug.assertNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertNode); }
- : ts.noop;
- Debug.assertOptionalNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
- : ts.noop;
- Debug.assertOptionalToken = Debug.shouldAssert(1 /* Normal */)
- ? function (node, kind, message) { return Debug.assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was not a '" + ts.formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
- : ts.noop;
- Debug.assertMissingNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, message) { return Debug.assert(node === undefined, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
- : ts.noop;
- /**
- * Injects debug information into frequently used types.
- */
- function enableDebugInfo() {
- if (isDebugInfoEnabled)
- return;
- // Add additional properties in debug mode to assist with debugging.
- Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatSymbolFlags(this.flags); } }
- });
- Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } },
- __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } },
- __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
- });
- var nodeConstructors = [
- ts.objectAllocator.getNodeConstructor(),
- ts.objectAllocator.getIdentifierConstructor(),
- ts.objectAllocator.getTokenConstructor(),
- ts.objectAllocator.getSourceFileConstructor()
- ];
- for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
- var ctor = nodeConstructors_1[_i];
- if (!ctor.prototype.hasOwnProperty("__debugKind")) {
- Object.defineProperties(ctor.prototype, {
- __debugKind: { get: function () { return ts.formatSyntaxKind(this.kind); } },
- __debugModifierFlags: { get: function () { return ts.formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
- __debugTransformFlags: { get: function () { return ts.formatTransformFlags(this.transformFlags); } },
- __debugEmitFlags: { get: function () { return ts.formatEmitFlags(ts.getEmitFlags(this)); } },
- __debugGetText: {
- value: function (includeTrivia) {
- if (ts.nodeIsSynthesized(this))
- return "";
- var parseNode = ts.getParseTreeNode(this);
- var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
- return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
- }
- }
- });
- }
- }
- isDebugInfoEnabled = true;
- }
- Debug.enableDebugInfo = enableDebugInfo;
- })(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
/* @internal */
var ts;
@@ -68974,8 +69027,8 @@ var ts;
* @param receiver The receiver on which each property should be assigned.
*/
function addInitializedPropertyStatements(statements, properties, receiver) {
- for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
- var property = properties_7[_i];
+ for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) {
+ var property = properties_6[_i];
var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver));
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
ts.setCommentRange(statement, property);
@@ -68991,8 +69044,8 @@ var ts;
*/
function generateInitializedPropertyExpressions(properties, receiver) {
var expressions = [];
- for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
- var property = properties_8[_i];
+ for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
+ var property = properties_7[_i];
var expression = transformInitializedProperty(property, receiver);
ts.startOnNewLine(expression);
ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
@@ -71534,6 +71587,8 @@ var ts;
return visitObjectLiteralExpression(node);
case 205 /* BinaryExpression */:
return visitBinaryExpression(node, noDestructuringValue);
+ case 275 /* CatchClause */:
+ return visitCatchClause(node);
case 238 /* VariableDeclaration */:
return visitVariableDeclaration(node);
case 228 /* ForOfStatement */:
@@ -71670,6 +71725,23 @@ var ts;
}
return ts.visitEachChild(node, visitor, context);
}
+ function visitCatchClause(node) {
+ if (node.variableDeclaration &&
+ ts.isBindingPattern(node.variableDeclaration.name) &&
+ node.variableDeclaration.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) {
+ var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
+ var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*type*/ undefined, name);
+ var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
+ var block = ts.visitNode(node.block, visitor, ts.isBlock);
+ if (ts.some(visitedBindings)) {
+ block = ts.updateBlock(block, [
+ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings)
+ ].concat(block.statements));
+ }
+ return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block);
+ }
+ return ts.visitEachChild(node, visitor, context);
+ }
/**
* Visits a VariableDeclaration node with a binding pattern.
*
@@ -72813,62 +72885,63 @@ var ts;
HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block";
HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement";
HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock";
- HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement";
- HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper";
+ HierarchyFacts[HierarchyFacts["IterationContainer"] = 1024] = "IterationContainer";
+ HierarchyFacts[HierarchyFacts["ForStatement"] = 2048] = "ForStatement";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 4096] = "ForInOrForOfStatement";
+ HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 8192] = "ConstructorWithCapturedSuper";
// NOTE: do not add more ancestor flags without also updating AncestorFactsMask below.
// NOTE: when adding a new ancestor flag, be sure to update the subtree flags below.
//
// Ancestor masks
//
- HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 8191] = "AncestorFactsMask";
+ HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask";
// We are always in *some* kind of block scope, but only specific block-scope containers are
// top-level or Blocks.
HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes";
- HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes";
+ HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 7104] = "BlockScopeExcludes";
// A source file is a top-level block scope.
HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes";
- HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes";
+ HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 8064] = "SourceFileExcludes";
// Functions, methods, and accessors are both new lexical scopes and new block scopes.
HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes";
- HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 8094] = "FunctionExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes";
HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes";
- HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 8086] = "AsyncFunctionBodyExcludes";
+ HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes";
// Arrow functions are lexically scoped to their container, but are new block scopes.
HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes";
- HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 8064] = "ArrowFunctionExcludes";
+ HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 15232] = "ArrowFunctionExcludes";
// Constructors are both new lexical scopes and new block scopes. Constructors are also
// always considered non-static members of a class.
HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes";
- HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 8086] = "ConstructorExcludes";
+ HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes";
// 'do' and 'while' statements are not block scopes. We track that the subtree is contained
// within an IterationStatement to indicate whether the embedded statement is an
// IterationStatementBlock.
- HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes";
+ HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 1280] = "DoOrWhileStatementIncludes";
HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes";
// 'for' statements are new block scopes and have special handling for 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 3328] = "ForStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 5056] = "ForStatementExcludes";
// 'for-in' and 'for-of' statements are new block scopes and have special handling for
// 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 5376] = "ForInOrForOfStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 3008] = "ForInOrForOfStatementExcludes";
// Blocks (other than function bodies) are new block scopes.
HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes";
- HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes";
+ HierarchyFacts[HierarchyFacts["BlockExcludes"] = 6976] = "BlockExcludes";
HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes";
- HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes";
+ HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 7104] = "IterationStatementBlockExcludes";
//
// Subtree facts
//
- HierarchyFacts[HierarchyFacts["NewTarget"] = 8192] = "NewTarget";
- HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 16384] = "CapturedLexicalThis";
+ HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget";
+ HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 32768] = "CapturedLexicalThis";
//
// Subtree masks
//
- HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -8192] = "SubtreeFactsMask";
+ HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask";
HierarchyFacts[HierarchyFacts["ArrowFunctionSubtreeExcludes"] = 0] = "ArrowFunctionSubtreeExcludes";
- HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 24576] = "FunctionSubtreeExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 49152] = "FunctionSubtreeExcludes";
})(HierarchyFacts || (HierarchyFacts = {}));
function transformES2015(context) {
var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
@@ -72917,7 +72990,7 @@ var ts;
*/
function enterSubtree(excludeFacts, includeFacts) {
var ancestorFacts = hierarchyFacts;
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 8191 /* AncestorFactsMask */;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */;
return ancestorFacts;
}
/**
@@ -72928,17 +73001,17 @@ var ts;
* @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated.
*/
function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -8192 /* SubtreeFactsMask */ | ancestorFacts;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts;
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
- return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0
+ return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0
&& node.kind === 231 /* ReturnStatement */
&& !node.expression;
}
function shouldVisitNode(node) {
return (node.transformFlags & 128 /* ContainsES2015 */) !== 0
|| convertedLoopState !== undefined
- || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
+ || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
|| (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node))
|| (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0;
}
@@ -73055,7 +73128,7 @@ var ts;
}
}
function visitSourceFile(node) {
- var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
+ var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
var prologue = [];
var statements = [];
startLexicalEnvironment();
@@ -73082,7 +73155,7 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitCaseBlock(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -73109,7 +73182,7 @@ var ts;
}
function visitThisKeyword(node) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
if (convertedLoopState) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
@@ -73352,7 +73425,7 @@ var ts;
function addConstructor(statements, node, extendsClauseElement) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8086 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
+ var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
var constructor = ts.getFirstConstructorWithBody(node);
var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
var constructorFunction = ts.createFunctionDeclaration(
@@ -73366,7 +73439,7 @@ var ts;
ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */);
}
statements.push(constructorFunction);
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
}
/**
@@ -73459,7 +73532,7 @@ var ts;
}
}
if (superCallExpression) {
- hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */;
+ hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
}
// visit the remaining statements
@@ -73763,7 +73836,7 @@ var ts;
* @param node A node.
*/
function insertCaptureThisForNodeIfNeeded(statements, node) {
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
insertCaptureThisForNode(statements, node, ts.createThis());
return true;
}
@@ -73781,7 +73854,7 @@ var ts;
ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
}
function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
- if (hierarchyFacts & 8192 /* NewTarget */) {
+ if (hierarchyFacts & 16384 /* NewTarget */) {
var newTarget = void 0;
switch (node.kind) {
case 198 /* ArrowFunction */:
@@ -73951,11 +74024,11 @@ var ts;
*/
function visitArrowFunction(node) {
if (node.transformFlags & 2048 /* ContainsLexicalThis */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8064 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
+ var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
var func = ts.createFunctionExpression(
/*modifiers*/ undefined,
/*asteriskToken*/ undefined,
@@ -73965,7 +74038,7 @@ var ts;
ts.setTextRange(func, node);
ts.setOriginalNode(func, node);
ts.setEmitFlags(func, 8 /* CapturesThis */);
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */) {
enableSubstitutionsForCapturedThis();
}
// If an arrow function contains
@@ -73980,16 +74053,16 @@ var ts;
*/
function visitFunctionExpression(node) {
var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */
- ? enterSubtree(8086 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionExpression(node,
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -74004,13 +74077,13 @@ var ts;
function visitFunctionDeclaration(node) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionDeclaration(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name,
@@ -74028,14 +74101,14 @@ var ts;
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */)
- ? enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- if (hierarchyFacts & 8192 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
+ if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
name = ts.getGeneratedNameForNode(node);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -74130,8 +74203,8 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */
- ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
- : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */);
+ ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
+ : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -74314,11 +74387,11 @@ var ts;
&& isDeclaredInLoop
&& (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0);
var emitExplicitInitializer = !emittedAsTopLevel
- && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0
+ && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0
&& (!resolver.isDeclarationWithCollidingName(node)
|| (isDeclaredInLoop
&& !isCapturedInFunction
- && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0));
+ && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0));
return emitExplicitInitializer;
}
/**
@@ -74389,21 +74462,21 @@ var ts;
}
function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
- var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert);
+ var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
}
function visitDoOrWhileStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
}
function visitForStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement);
}
function visitForInStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
}
function visitForOfStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
}
function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
var statements = [];
@@ -74511,7 +74584,7 @@ var ts;
ts.setTextRange(forStatement, node);
return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
}
- function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) {
+ function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined);
var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined);
@@ -74522,9 +74595,13 @@ var ts;
var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []);
hoistVariableDeclaration(errorRecord);
hoistVariableDeclaration(returnMethod);
+ // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration
+ var initializer = ancestorFacts & 1024 /* IterationContainer */
+ ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
+ : values;
var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(
/*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
- ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression),
+ ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, initializer), node.expression),
ts.createVariableDeclaration(result, /*type*/ undefined, next)
]), node.expression), 2097152 /* NoHoisting */),
/*condition*/ ts.createLogicalNot(ts.createPropertyAccess(result, "done")),
@@ -74635,7 +74712,7 @@ var ts;
}
}
}
- function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) {
+ function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
if (!shouldConvertIterationStatement(node)) {
var saveAllowedNonLabeledJumps = void 0;
if (convertedLoopState) {
@@ -74645,7 +74722,7 @@ var ts;
convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */;
}
var result = convert
- ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined)
+ ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts)
: ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
if (convertedLoopState) {
convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
@@ -74670,7 +74747,7 @@ var ts;
var loop;
if (bodyFunction) {
if (convert) {
- loop = convert(node, outermostLabeledStatement, bodyFunction.part);
+ loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
}
else {
var clone_3 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, /*multiLine*/ true));
@@ -75188,7 +75265,7 @@ var ts;
return expression;
}
function visitCatchClause(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated;
ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
if (ts.isBindingPattern(node.variableDeclaration.name)) {
@@ -75236,7 +75313,7 @@ var ts;
ts.Debug.assert(!ts.isComputedPropertyName(node.name));
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var updated;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
@@ -75246,7 +75323,7 @@ var ts;
else {
updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return updated;
}
@@ -75732,7 +75809,7 @@ var ts;
}
function visitMetaProperty(node) {
if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") {
- hierarchyFacts |= 8192 /* NewTarget */;
+ hierarchyFacts |= 16384 /* NewTarget */;
return ts.createFileLevelUniqueName("_newTarget");
}
return node;
@@ -75747,7 +75824,7 @@ var ts;
function onEmitNode(hint, node, emitCallback) {
if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) {
// If we are tracking a captured `this`, keep track of the enclosing function.
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
? 65 /* FunctionIncludes */ | 16 /* CapturesThis */
: 65 /* FunctionIncludes */);
previousOnEmitNode(hint, node, emitCallback);
@@ -87681,6 +87758,8 @@ var ts;
case 159 /* GetAccessor */:
case 160 /* SetAccessor */:
return generateNameForMethodOrAccessor(node);
+ case 150 /* ComputedPropertyName */:
+ return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true);
default:
return makeTempVariableName(0 /* Auto */);
}
@@ -90372,7 +90451,10 @@ var ts;
if (isRedirect) {
inputName = getProjectReferenceRedirect(fileName) || fileName;
}
- if (ts.getNormalizedAbsolutePath(checkedName, currentDirectory) !== ts.getNormalizedAbsolutePath(inputName, currentDirectory)) {
+ // Check if it differs only in drive letters its ok to ignore that error:
+ var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
+ var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory);
+ if (checkedAbsolutePath !== inputAbsolutePath) {
reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd);
}
}
@@ -90908,10 +90990,10 @@ var ts;
if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
}
- var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
+ var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
@@ -93312,11 +93394,11 @@ var ts;
}
function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
var result = ts.createMap();
- var symlinks = ts.mapDefined(files, function (sf) {
- return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) {
+ var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
+ return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
- });
- });
+ })));
+ }));
for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];
@@ -98702,7 +98784,7 @@ var ts;
var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of.
var entries = pathCompletions.map(function (_a) {
var name = _a.name, kind = _a.kind, span = _a.span, extension = _a.extension;
- return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: "0", replacementSpan: span });
+ return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: Completions.SortText.LocationPriority, replacementSpan: span });
});
return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
}
@@ -99305,6 +99387,14 @@ var ts;
(function (ts) {
var Completions;
(function (Completions) {
+ var SortText;
+ (function (SortText) {
+ SortText["LocationPriority"] = "0";
+ SortText["SuggestedClassMembers"] = "1";
+ SortText["GlobalsOrKeywords"] = "2";
+ SortText["AutoImportSuggestions"] = "3";
+ SortText["JavascriptIdentifiers"] = "4";
+ })(SortText = Completions.SortText || (Completions.SortText = {}));
var SymbolOriginInfoKind;
(function (SymbolOriginInfoKind) {
SymbolOriginInfoKind[SymbolOriginInfoKind["ThisType"] = 0] = "ThisType";
@@ -99339,8 +99429,9 @@ var ts;
var typeChecker = program.getTypeChecker();
var compilerOptions = program.getCompilerOptions();
var contextToken = ts.findPrecedingToken(position, sourceFile);
- if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position))
+ if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) {
return undefined;
+ }
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences);
if (stringCompletions) {
return stringCompletions;
@@ -99373,7 +99464,7 @@ var ts;
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries };
}
function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) {
- var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression;
+ var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap;
if (location && location.parent && ts.isJsxClosingElement(location.parent)) {
// In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag,
// instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element.
@@ -99387,20 +99478,20 @@ var ts;
name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"),
kind: "class" /* classElement */,
kindModifiers: undefined,
- sortText: "0",
+ sortText: SortText.LocationPriority,
};
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [entry] };
}
var entries = [];
if (isUncheckedFile(sourceFile, compilerOptions)) {
- var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap);
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217
}
else {
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
return undefined;
}
- getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap);
+ getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
}
if (keywordFilters !== 0 /* None */) {
var entryNames = ts.arrayToSet(entries, function (e) { return e.name; });
@@ -99442,7 +99533,7 @@ var ts;
name: realName,
kind: "warning" /* warning */,
kindModifiers: "",
- sortText: "1"
+ sortText: SortText.JavascriptIdentifiers
});
}
});
@@ -99451,14 +99542,9 @@ var ts;
return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal);
};
function createCompletionEntryForLiteral(literal) {
- return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: "0" };
+ return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
}
- function createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
- var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
- if (!info) {
- return undefined;
- }
- var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
+ function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
var insertText;
var replacementSpan;
if (origin && origin.kind === 0 /* ThisType */) {
@@ -99495,7 +99581,7 @@ var ts;
name: name,
kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol),
- sortText: "0",
+ sortText: sortText,
source: getSourceFromOrigin(origin),
hasAction: trueOrUndefined(!!origin && originIsExport(origin)),
isRecommended: trueOrUndefined(isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker)),
@@ -99513,7 +99599,7 @@ var ts;
function getSourceFromOrigin(origin) {
return origin && originIsExport(origin) ? ts.stripQuotes(origin.moduleSymbol.name) : undefined;
}
- function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap) {
+ function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) {
var start = ts.timestamp();
// Tracks unique names.
// We don't set this for global variables or completions from external module exports, because we can have multiple of those.
@@ -99523,14 +99609,18 @@ var ts;
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
var symbol = symbols_1[_i];
var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined;
- var entry = createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
- if (!entry) {
+ var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
+ if (!info) {
continue;
}
- var name = entry.name;
+ var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
if (uniques.has(name)) {
continue;
}
+ var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
+ if (!entry) {
+ continue;
+ }
// Latter case tests whether this is a global variable.
if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { // TODO: GH#18217
uniques.set(name, true);
@@ -99563,7 +99653,7 @@ var ts;
name: name,
kindModifiers: "" /* none */,
kind: "label" /* label */,
- sortText: "0"
+ sortText: SortText.LocationPriority
});
}
}
@@ -99940,6 +100030,7 @@ var ts;
var keywordFilters = 0 /* None */;
var symbols = [];
var symbolToOriginInfoMap = [];
+ var symbolToSortTextMap = [];
if (isRightOfDot) {
getTypeScriptMemberSymbols();
}
@@ -99985,7 +100076,8 @@ var ts;
recommendedCompletion: recommendedCompletion,
previousToken: previousToken,
isJsxInitializer: isJsxInitializer,
- insideJsDocTagTypeExpression: insideJsDocTagTypeExpression
+ insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
+ symbolToSortTextMap: symbolToSortTextMap
};
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
@@ -100167,14 +100259,22 @@ var ts;
var isTypeOnly = isTypeOnlyCompletion();
var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined");
+ for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
+ var symbol = symbols_2[_i];
+ if (!typeChecker.isArgumentsSymbol(symbol) &&
+ !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords;
+ }
+ }
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) {
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
if (thisType) {
- for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
- var symbol = _a[_i];
+ for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
+ var symbol = _b[_a];
symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ };
symbols.push(symbol);
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers;
}
}
}
@@ -100293,6 +100393,7 @@ var ts;
// So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`.
ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) {
symbols.push(resolvedModuleSymbol);
+ symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions;
symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false };
}
for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) {
@@ -100317,6 +100418,7 @@ var ts;
var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport };
if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) {
symbols.push(symbol);
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions;
symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin;
}
}
@@ -100953,7 +101055,7 @@ var ts;
name: ts.tokenToString(i),
kind: "keyword" /* keyword */,
kindModifiers: "" /* none */,
- sortText: "0"
+ sortText: SortText.GlobalsOrKeywords
});
}
return res;
@@ -101804,7 +101906,7 @@ var ts;
directImports.push(direct);
break;
default:
- ts.Debug.assertNever(direct, "Unexpected import kind: " + ts.Debug.showSyntaxKind(direct));
+ ts.Debug.failBadSyntaxKind(direct, "Unexpected import kind.");
}
}
}
@@ -102147,7 +102249,7 @@ var ts;
var sym = useLhsSymbol ? checker.getSymbolAtLocation(ts.cast(node.left, ts.isPropertyAccessExpression).name) : symbol;
// Better detection for GH#20803
if (sym && !(checker.getMergedSymbol(sym.parent).flags & 1536 /* Module */)) {
- ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.showSymbol(sym) + ", parent is " + ts.Debug.showSymbol(sym.parent));
+ ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.formatSymbol(sym) + ", parent is " + ts.Debug.formatSymbol(sym.parent));
}
return sym && exportInfo(sym, kind);
}
@@ -102847,7 +102949,7 @@ var ts;
if (symbol.flags & 33554432 /* Transient */)
return undefined;
// Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here.
- ts.Debug.fail("Unexpected symbol at " + ts.Debug.showSyntaxKind(node) + ": " + ts.Debug.showSymbol(symbol));
+ ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol));
}
return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent)
? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name)
@@ -102952,8 +103054,8 @@ var ts;
var sourceId = ts.getNodeId(sourceFile);
var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = ts.createMap());
var anyNewSymbols = false;
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
- var sym = symbols_2[_i];
+ for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) {
+ var sym = symbols_3[_i];
anyNewSymbols = ts.addToSeen(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
}
return anyNewSymbols;
@@ -107412,8 +107514,21 @@ var ts;
});
}
function containsPrecedingToken(startingToken, sourceFile, container) {
- var precedingToken = ts.Debug.assertDefined(ts.findPrecedingToken(startingToken.getFullStart(), sourceFile, startingToken.parent, /*excludeJsdoc*/ true));
- return ts.rangeContainsRange(container, precedingToken);
+ var pos = startingToken.getFullStart();
+ // There’s a possibility that `startingToken.parent` contains only `startingToken` and
+ // missing nodes, none of which are valid to be returned by `findPrecedingToken`. In that
+ // case, the preceding token we want is actually higher up the tree—almost definitely the
+ // next parent, but theoretically the situation with missing nodes might be happening on
+ // multiple nested levels.
+ var currentParent = startingToken.parent;
+ while (currentParent) {
+ var precedingToken = ts.findPrecedingToken(pos, sourceFile, currentParent, /*excludeJsdoc*/ true);
+ if (precedingToken) {
+ return ts.rangeContainsRange(container, precedingToken);
+ }
+ currentParent = currentParent.parent;
+ }
+ return ts.Debug.fail("Could not find preceding token");
}
function getArgumentInfoForCompletions(node, position, sourceFile) {
var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile);
@@ -107703,7 +107818,7 @@ var ts;
var _loop_7 = function (n) {
// If the node is not a subspan of its parent, this is a big problem.
// There have been crashes that might be caused by this violation.
- ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); });
+ ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); });
var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker);
if (argumentInfo) {
return { value: argumentInfo };
@@ -112769,11 +112884,11 @@ var ts;
function makeChange(changeTracker, sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
if (!ts.isIdentifier(token)) {
- return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.formatSyntaxKind(token.kind));
+ return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.Debug.formatSyntaxKind(token.kind));
}
var param = token.parent;
if (!ts.isParameter(param)) {
- return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.formatSyntaxKind(token.kind));
+ return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.Debug.formatSyntaxKind(token.kind));
}
var i = param.parent.parameters.indexOf(param);
ts.Debug.assert(!param.type, "Tried to add a parameter name to a parameter that already had one.");
@@ -120909,7 +121024,7 @@ var ts;
var textPos = ts.scanner.getTextPos();
if (textPos <= end) {
if (token === 73 /* Identifier */) {
- ts.Debug.fail("Did not expect " + ts.Debug.showSyntaxKind(parent) + " to have an Identifier in its trivia");
+ ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia");
}
nodes.push(createNode(token, pos, textPos, parent));
}
@@ -125547,13 +125662,13 @@ var ts;
server.updateProjectIfDirty(this);
return hasOneOrMoreJsAndNoTsFiles(this);
};
- Project.resolveModule = function (moduleName, initialDir, host, log) {
+ Project.resolveModule = function (moduleName, initialDir, host, log, logErrors) {
var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules")));
log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
var result = host.require(resolvedPath, moduleName); // TODO: GH#18217
if (result.error) {
var err = result.error.stack || result.error.message || JSON.stringify(result.error);
- log("Failed to load module '" + moduleName + "': " + err);
+ (logErrors || log)("Failed to load module '" + moduleName + "' from " + resolvedPath + ": " + err);
return undefined;
}
return result.module;
@@ -126311,11 +126426,11 @@ var ts;
Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
var _this = this;
this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
- var log = function (message) {
- _this.projectService.logger.info(message);
- };
+ var log = function (message) { return _this.projectService.logger.info(message); };
+ var errorLogs;
+ var logError = function (message) { (errorLogs || (errorLogs = [])).push(message); };
var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
- return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log);
+ return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
});
if (resolvedModule) {
var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
@@ -126328,6 +126443,7 @@ var ts;
this.enableProxy(resolvedModule, pluginConfigEntry);
}
else {
+ ts.forEach(errorLogs, log);
this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
}
};
diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts
index 4b06bc9e8392a..993a7494994be 100644
--- a/lib/tsserverlibrary.d.ts
+++ b/lib/tsserverlibrary.d.ts
@@ -1969,6 +1969,7 @@ declare namespace ts {
*/
getExportSymbolOfSymbol(symbol: Symbol): Symbol;
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
+ getTypeOfAssignmentPattern(pattern: AssignmentPattern): Type;
getTypeAtLocation(node: Node): Type;
getTypeFromTypeNode(node: TypeNode): Type;
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
@@ -8320,7 +8321,7 @@ declare namespace ts.server {
private readonly cancellationToken;
isNonTsProject(): boolean;
isJsOnlyProject(): boolean;
- static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} | undefined;
+ static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void, logErrors?: (message: string) => void): {} | undefined;
isKnownTypesPackageName(name: string): boolean;
installPackage(options: InstallPackageOptions): Promise;
private readonly typingsCache;
diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js
index 7158a5452faa6..aaf01702b9691 100644
--- a/lib/tsserverlibrary.js
+++ b/lib/tsserverlibrary.js
@@ -86,7 +86,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.5";
/** The version of the TypeScript compiler release */
- ts.version = ts.versionMajorMinor + ".0-rc";
+ ts.version = ts.versionMajorMinor + ".1";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@@ -326,7 +326,7 @@ var ts;
ts.firstDefinedIterator = firstDefinedIterator;
function zipWith(arrayA, arrayB, callback) {
var result = [];
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
for (var i = 0; i < arrayA.length; i++) {
result.push(callback(arrayA[i], arrayB[i], i));
}
@@ -334,7 +334,7 @@ var ts;
}
ts.zipWith = zipWith;
function zipToIterator(arrayA, arrayB) {
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
var i = 0;
return {
next: function () {
@@ -348,7 +348,7 @@ var ts;
}
ts.zipToIterator = zipToIterator;
function zipToMap(keys, values) {
- Debug.assert(keys.length === values.length);
+ ts.Debug.assert(keys.length === values.length);
var map = createMap();
for (var i = 0; i < keys.length; ++i) {
map.set(keys[i], values[i]);
@@ -422,7 +422,7 @@ var ts;
return result;
}
}
- return Debug.fail();
+ return ts.Debug.fail();
}
ts.findMap = findMap;
function contains(array, value, equalityComparer) {
@@ -852,7 +852,7 @@ var ts;
continue;
case -1 /* LessThan */:
// If `array` is sorted, `next` should **never** be less than `last`.
- return Debug.fail("Array is unsorted.");
+ return ts.Debug.fail("Array is unsorted.");
}
deduplicated.push(last = next);
}
@@ -919,13 +919,13 @@ var ts;
loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
if (offsetB > 0) {
// Ensure `arrayB` is properly sorted.
- Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
}
loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
if (offsetA > startA) {
// Ensure `arrayA` is properly sorted. We only need to perform this check if
// `offsetA` has changed since we entered the loop.
- Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
}
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
case -1 /* LessThan */:
@@ -1095,7 +1095,7 @@ var ts;
}
ts.firstOrUndefined = firstOrUndefined;
function first(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[0];
}
ts.first = first;
@@ -1107,7 +1107,7 @@ var ts;
}
ts.lastOrUndefined = lastOrUndefined;
function last(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[array.length - 1];
}
ts.last = last;
@@ -1432,7 +1432,7 @@ var ts;
function cast(value, test) {
if (value !== undefined && test(value))
return value;
- return Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + Debug.getFunctionName(test) + "'.");
+ return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
}
ts.cast = cast;
/** Does nothing. */
@@ -1501,92 +1501,6 @@ var ts;
AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive";
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
})(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {}));
- var Debug;
- (function (Debug) {
- Debug.currentAssertionLevel = 0 /* None */;
- Debug.isDebugging = false;
- function shouldAssert(level) {
- return Debug.currentAssertionLevel >= level;
- }
- Debug.shouldAssert = shouldAssert;
- function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
- if (!expression) {
- if (verboseDebugInfo) {
- message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
- }
- fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
- }
- }
- Debug.assert = assert;
- function assertEqual(a, b, msg, msg2) {
- if (a !== b) {
- var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
- fail("Expected " + a + " === " + b + ". " + message);
- }
- }
- Debug.assertEqual = assertEqual;
- function assertLessThan(a, b, msg) {
- if (a >= b) {
- fail("Expected " + a + " < " + b + ". " + (msg || ""));
- }
- }
- Debug.assertLessThan = assertLessThan;
- function assertLessThanOrEqual(a, b) {
- if (a > b) {
- fail("Expected " + a + " <= " + b);
- }
- }
- Debug.assertLessThanOrEqual = assertLessThanOrEqual;
- function assertGreaterThanOrEqual(a, b) {
- if (a < b) {
- fail("Expected " + a + " >= " + b);
- }
- }
- Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
- function fail(message, stackCrawlMark) {
- debugger;
- var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
- if (Error.captureStackTrace) {
- Error.captureStackTrace(e, stackCrawlMark || fail);
- }
- throw e;
- }
- Debug.fail = fail;
- function assertDefined(value, message) {
- if (value === undefined || value === null)
- return fail(message);
- return value;
- }
- Debug.assertDefined = assertDefined;
- function assertEachDefined(value, message) {
- for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
- var v = value_1[_i];
- assertDefined(v, message);
- }
- return value;
- }
- Debug.assertEachDefined = assertEachDefined;
- function assertNever(member, message, stackCrawlMark) {
- if (message === void 0) { message = "Illegal value:"; }
- var detail = typeof member === "object" && "kind" in member && "pos" in member ? "SyntaxKind: " + Debug.showSyntaxKind(member) : JSON.stringify(member);
- return fail(message + " " + detail, stackCrawlMark || assertNever);
- }
- Debug.assertNever = assertNever;
- function getFunctionName(func) {
- if (typeof func !== "function") {
- return "";
- }
- else if (func.hasOwnProperty("name")) {
- return func.name;
- }
- else {
- var text = Function.prototype.toString.call(func);
- var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
- return match ? match[1] : "";
- }
- }
- Debug.getFunctionName = getFunctionName;
- })(Debug = ts.Debug || (ts.Debug = {}));
function equateValues(a, b) {
return a === b;
}
@@ -1843,7 +1757,7 @@ var ts;
bestCandidate = candidate;
}
else {
- Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
+ ts.Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
bestDistance = distance;
bestCandidate = candidate;
}
@@ -1987,7 +1901,7 @@ var ts;
* E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar"
*/
function matchedText(pattern, candidate) {
- Debug.assert(isPatternMatch(pattern, candidate));
+ ts.Debug.assert(isPatternMatch(pattern, candidate));
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
}
ts.matchedText = matchedText;
@@ -2106,6 +2020,242 @@ var ts;
}
}
})(ts || (ts = {}));
+/* @internal */
+var ts;
+(function (ts) {
+ var Debug;
+ (function (Debug) {
+ Debug.currentAssertionLevel = 0 /* None */;
+ Debug.isDebugging = false;
+ function shouldAssert(level) {
+ return Debug.currentAssertionLevel >= level;
+ }
+ Debug.shouldAssert = shouldAssert;
+ function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
+ if (!expression) {
+ if (verboseDebugInfo) {
+ message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
+ }
+ fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
+ }
+ }
+ Debug.assert = assert;
+ function assertEqual(a, b, msg, msg2) {
+ if (a !== b) {
+ var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
+ fail("Expected " + a + " === " + b + ". " + message);
+ }
+ }
+ Debug.assertEqual = assertEqual;
+ function assertLessThan(a, b, msg) {
+ if (a >= b) {
+ fail("Expected " + a + " < " + b + ". " + (msg || ""));
+ }
+ }
+ Debug.assertLessThan = assertLessThan;
+ function assertLessThanOrEqual(a, b) {
+ if (a > b) {
+ fail("Expected " + a + " <= " + b);
+ }
+ }
+ Debug.assertLessThanOrEqual = assertLessThanOrEqual;
+ function assertGreaterThanOrEqual(a, b) {
+ if (a < b) {
+ fail("Expected " + a + " >= " + b);
+ }
+ }
+ Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
+ function fail(message, stackCrawlMark) {
+ debugger;
+ var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(e, stackCrawlMark || fail);
+ }
+ throw e;
+ }
+ Debug.fail = fail;
+ function assertDefined(value, message) {
+ if (value === undefined || value === null)
+ return fail(message);
+ return value;
+ }
+ Debug.assertDefined = assertDefined;
+ function assertEachDefined(value, message) {
+ for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
+ var v = value_1[_i];
+ assertDefined(v, message);
+ }
+ return value;
+ }
+ Debug.assertEachDefined = assertEachDefined;
+ function assertNever(member, message, stackCrawlMark) {
+ if (message === void 0) { message = "Illegal value:"; }
+ var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
+ return fail(message + " " + detail, stackCrawlMark || assertNever);
+ }
+ Debug.assertNever = assertNever;
+ function getFunctionName(func) {
+ if (typeof func !== "function") {
+ return "";
+ }
+ else if (func.hasOwnProperty("name")) {
+ return func.name;
+ }
+ else {
+ var text = Function.prototype.toString.call(func);
+ var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
+ return match ? match[1] : "";
+ }
+ }
+ Debug.getFunctionName = getFunctionName;
+ function formatSymbol(symbol) {
+ return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
+ }
+ Debug.formatSymbol = formatSymbol;
+ /**
+ * Formats an enum value as a string for debugging and debug assertions.
+ */
+ function formatEnum(value, enumObject, isFlags) {
+ if (value === void 0) { value = 0; }
+ var members = getEnumMembers(enumObject);
+ if (value === 0) {
+ return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
+ }
+ if (isFlags) {
+ var result = "";
+ var remainingFlags = value;
+ for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
+ var _a = members[i], enumValue = _a[0], enumName = _a[1];
+ if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
+ remainingFlags &= ~enumValue;
+ result = "" + enumName + (result ? "|" : "") + result;
+ }
+ }
+ if (remainingFlags === 0) {
+ return result;
+ }
+ }
+ else {
+ for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
+ var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
+ if (enumValue === value) {
+ return enumName;
+ }
+ }
+ }
+ return value.toString();
+ }
+ Debug.formatEnum = formatEnum;
+ function getEnumMembers(enumObject) {
+ var result = [];
+ for (var name in enumObject) {
+ var value = enumObject[name];
+ if (typeof value === "number") {
+ result.push([value, name]);
+ }
+ }
+ return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
+ }
+ function formatSyntaxKind(kind) {
+ return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
+ }
+ Debug.formatSyntaxKind = formatSyntaxKind;
+ function formatNodeFlags(flags) {
+ return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
+ }
+ Debug.formatNodeFlags = formatNodeFlags;
+ function formatModifierFlags(flags) {
+ return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
+ }
+ Debug.formatModifierFlags = formatModifierFlags;
+ function formatTransformFlags(flags) {
+ return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
+ }
+ Debug.formatTransformFlags = formatTransformFlags;
+ function formatEmitFlags(flags) {
+ return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
+ }
+ Debug.formatEmitFlags = formatEmitFlags;
+ function formatSymbolFlags(flags) {
+ return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
+ }
+ Debug.formatSymbolFlags = formatSymbolFlags;
+ function formatTypeFlags(flags) {
+ return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
+ }
+ Debug.formatTypeFlags = formatTypeFlags;
+ function formatObjectFlags(flags) {
+ return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
+ }
+ Debug.formatObjectFlags = formatObjectFlags;
+ function failBadSyntaxKind(node, message) {
+ return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
+ }
+ Debug.failBadSyntaxKind = failBadSyntaxKind;
+ Debug.assertEachNode = shouldAssert(1 /* Normal */)
+ ? function (nodes, test, message) { return assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertEachNode); }
+ : ts.noop;
+ Debug.assertNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); }
+ : ts.noop;
+ Debug.assertOptionalNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
+ : ts.noop;
+ Debug.assertOptionalToken = shouldAssert(1 /* Normal */)
+ ? function (node, kind, message) { return assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
+ : ts.noop;
+ Debug.assertMissingNode = shouldAssert(1 /* Normal */)
+ ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
+ : ts.noop;
+ var isDebugInfoEnabled = false;
+ /**
+ * Injects debug information into frequently used types.
+ */
+ function enableDebugInfo() {
+ if (isDebugInfoEnabled)
+ return;
+ // Add additional properties in debug mode to assist with debugging.
+ Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
+ __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
+ });
+ Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
+ __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
+ __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } },
+ __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
+ });
+ var nodeConstructors = [
+ ts.objectAllocator.getNodeConstructor(),
+ ts.objectAllocator.getIdentifierConstructor(),
+ ts.objectAllocator.getTokenConstructor(),
+ ts.objectAllocator.getSourceFileConstructor()
+ ];
+ for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
+ var ctor = nodeConstructors_1[_i];
+ if (!ctor.prototype.hasOwnProperty("__debugKind")) {
+ Object.defineProperties(ctor.prototype, {
+ __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
+ __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
+ __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
+ __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
+ __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
+ __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
+ __debugGetText: {
+ value: function (includeTrivia) {
+ if (ts.nodeIsSynthesized(this))
+ return "";
+ var parseNode = ts.getParseTreeNode(this);
+ var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
+ return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
+ }
+ }
+ });
+ }
+ }
+ isDebugInfoEnabled = true;
+ }
+ Debug.enableDebugInfo = enableDebugInfo;
+ })(Debug = ts.Debug || (ts.Debug = {}));
+})(ts || (ts = {}));
/*@internal*/
var ts;
(function (ts) {
@@ -5334,7 +5484,7 @@ var ts;
Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."),
Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
- Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", "Cannot compile namespaces when the '--isolatedModules' flag is provided."),
+ All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."),
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."),
A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
@@ -6121,7 +6271,6 @@ var ts;
Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."),
Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
Multiple_consecutive_numeric_separators_are_not_permitted: diag(6189, ts.DiagnosticCategory.Error, "Multiple_consecutive_numeric_separators_are_not_permitted_6189", "Multiple consecutive numeric separators are not permitted."),
- Found_package_json_at_0_Package_ID_is_1: diag(6190, ts.DiagnosticCategory.Message, "Found_package_json_at_0_Package_ID_is_1_6190", "Found 'package.json' at '{0}'. Package ID is '{1}'."),
Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: diag(6191, ts.DiagnosticCategory.Message, "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191", "Whether to keep outdated console output in watch mode instead of clearing the screen."),
All_imports_in_import_declaration_are_unused: diag(6192, ts.DiagnosticCategory.Error, "All_imports_in_import_declaration_are_unused_6192", "All imports in import declaration are unused.", /*reportsUnnecessary*/ true),
Found_1_error_Watching_for_file_changes: diag(6193, ts.DiagnosticCategory.Message, "Found_1_error_Watching_for_file_changes_6193", "Found 1 error. Watching for file changes."),
@@ -6148,6 +6297,9 @@ var ts;
Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."),
Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
+ Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"),
+ Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"),
+ package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."),
Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
@@ -6237,6 +6389,8 @@ var ts;
_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."),
Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1: diag(7051, ts.DiagnosticCategory.Error, "Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1_7051", "Parameter has a name but no type. Did you mean '{0}: {1}'?"),
Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1: diag(7052, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1_7052", "Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}' ?"),
+ Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: diag(7053, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053", "Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'."),
+ No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1: diag(7054, ts.DiagnosticCategory.Error, "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054", "No index signature with a parameter of type '{0}' was found on type '{1}'."),
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."),
@@ -10310,7 +10464,7 @@ var ts;
}
ts.isFunctionSymbol = isFunctionSymbol;
function importFromModuleSpecifier(node) {
- return tryGetImportFromModuleSpecifier(node) || ts.Debug.fail(ts.Debug.showSyntaxKind(node.parent));
+ return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
}
ts.importFromModuleSpecifier = importFromModuleSpecifier;
function tryGetImportFromModuleSpecifier(node) {
@@ -12265,77 +12419,6 @@ var ts;
return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
- /**
- * Formats an enum value as a string for debugging and debug assertions.
- */
- function formatEnum(value, enumObject, isFlags) {
- if (value === void 0) { value = 0; }
- var members = getEnumMembers(enumObject);
- if (value === 0) {
- return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
- }
- if (isFlags) {
- var result = "";
- var remainingFlags = value;
- for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
- var _a = members[i], enumValue = _a[0], enumName = _a[1];
- if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
- remainingFlags &= ~enumValue;
- result = "" + enumName + (result ? ", " : "") + result;
- }
- }
- if (remainingFlags === 0) {
- return result;
- }
- }
- else {
- for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
- var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
- if (enumValue === value) {
- return enumName;
- }
- }
- }
- return value.toString();
- }
- function getEnumMembers(enumObject) {
- var result = [];
- for (var name in enumObject) {
- var value = enumObject[name];
- if (typeof value === "number") {
- result.push([value, name]);
- }
- }
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
- }
- function formatSyntaxKind(kind) {
- return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
- }
- ts.formatSyntaxKind = formatSyntaxKind;
- function formatModifierFlags(flags) {
- return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
- }
- ts.formatModifierFlags = formatModifierFlags;
- function formatTransformFlags(flags) {
- return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
- }
- ts.formatTransformFlags = formatTransformFlags;
- function formatEmitFlags(flags) {
- return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
- }
- ts.formatEmitFlags = formatEmitFlags;
- function formatSymbolFlags(flags) {
- return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
- }
- ts.formatSymbolFlags = formatSymbolFlags;
- function formatTypeFlags(flags) {
- return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
- }
- ts.formatTypeFlags = formatTypeFlags;
- function formatObjectFlags(flags) {
- return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
- }
- ts.formatObjectFlags = formatObjectFlags;
/**
* Creates a new TextRange from the provided pos and end.
*
@@ -15529,6 +15612,15 @@ var ts;
return root + pathComponents.slice(1).join(ts.directorySeparator);
}
ts.getPathFromPathComponents = getPathFromPathComponents;
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
+ }
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
+ function getPathWithoutRoot(pathComponents) {
+ if (pathComponents.length === 0)
+ return "";
+ return pathComponents.slice(1).join(ts.directorySeparator);
+ }
})(ts || (ts = {}));
/* @internal */
(function (ts) {
@@ -15559,7 +15651,7 @@ var ts;
}
ts.getRelativePathFromFile = getRelativePathFromFile;
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
- Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
+ ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
@@ -16203,32 +16295,9 @@ var ts;
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
}
ts.changeAnyExtension = changeAnyExtension;
- var Debug;
- (function (Debug) {
- function showSymbol(symbol) {
- var symbolFlags = ts.SymbolFlags;
- return "{ flags: " + (symbolFlags ? showFlags(symbol.flags, symbolFlags) : symbol.flags) + "; declarations: " + ts.map(symbol.declarations, showSyntaxKind) + " }";
- }
- Debug.showSymbol = showSymbol;
- function showFlags(flags, flagsEnum) {
- var out = [];
- for (var pow = 0; pow <= 30; pow++) {
- var n = 1 << pow;
- if (flags & n) {
- out.push(flagsEnum[n]);
- }
- }
- return out.join("|");
- }
- function showSyntaxKind(node) {
- var syntaxKind = ts.SyntaxKind;
- return syntaxKind ? syntaxKind[node.kind] : node.kind.toString();
- }
- Debug.showSyntaxKind = showSyntaxKind;
- })(Debug = ts.Debug || (ts.Debug = {}));
function tryParsePattern(pattern) {
// This should be verified outside of here and a proper error thrown.
- Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
+ ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
var indexOfStar = pattern.indexOf("*");
return indexOfStar === -1 ? undefined : {
prefix: pattern.substr(0, indexOfStar),
@@ -16257,7 +16326,7 @@ var ts;
*/
function extensionFromPath(path) {
var ext = tryGetExtensionFromPath(path);
- return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension.");
+ return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
}
ts.extensionFromPath = extensionFromPath;
function isAnySupportedFileExtension(path) {
@@ -16329,7 +16398,7 @@ var ts;
ts.matchPatternOrExact = matchPatternOrExact;
function sliceAfter(arr, value) {
var index = arr.indexOf(value);
- Debug.assert(index !== -1);
+ ts.Debug.assert(index !== -1);
return arr.slice(index);
}
ts.sliceAfter = sliceAfter;
@@ -16347,7 +16416,7 @@ var ts;
}
ts.addRelatedInfo = addRelatedInfo;
function minAndMax(arr, getValue) {
- Debug.assert(arr.length !== 0);
+ ts.Debug.assert(arr.length !== 0);
var min = getValue(arr[0]);
var max = min;
for (var i = 1; i < arr.length; i++) {
@@ -25743,7 +25812,7 @@ var ts;
if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) {
extendedConfigPath = extendedConfigPath + ".json";
if (!host.fileExists(extendedConfigPath)) {
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
}
@@ -25754,7 +25823,7 @@ var ts;
if (resolved.resolvedModule) {
return resolved.resolvedModule.resolvedFileName;
}
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
@@ -26269,11 +26338,22 @@ var ts;
return !!compilerOptions.traceResolution && host.trace !== undefined;
}
ts.isTraceEnabled = isTraceEnabled;
- function withPackageId(packageId, r) {
+ function withPackageId(packageInfo, r) {
+ var packageId;
+ if (r && packageInfo) {
+ var packageJsonContent = packageInfo.packageJsonContent;
+ if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
+ packageId = {
+ name: packageJsonContent.name,
+ subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
+ version: packageJsonContent.version
+ };
+ }
+ }
return r && { path: r.path, extension: r.ext, packageId: packageId };
}
function noPackageId(r) {
- return withPackageId(/*packageId*/ undefined, r);
+ return withPackageId(/*packageInfo*/ undefined, r);
}
function removeIgnoredPackageId(r) {
if (r) {
@@ -26325,8 +26405,15 @@ var ts;
}
function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
- if (fileName === undefined)
+ if (fileName === undefined) {
+ return;
+ }
+ if (!fileName) {
+ if (state.traceEnabled) {
+ trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
+ }
return;
+ }
var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
@@ -26479,7 +26566,12 @@ var ts;
var fileName = resolved.fileName, packageId = resolved.packageId;
var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
if (traceEnabled) {
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ if (packageId) {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary);
+ }
+ else {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ }
}
resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
}
@@ -26767,7 +26859,12 @@ var ts;
}
if (traceEnabled) {
if (result.resolvedModule) {
- trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ if (result.resolvedModule.packageId) {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2, moduleName, result.resolvedModule.resolvedFileName, ts.packageIdToString(result.resolvedModule.packageId));
+ }
+ else {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ }
}
else {
trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
@@ -27037,10 +27134,9 @@ var ts;
}
var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
if (resolvedFromFile) {
- var nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
- var packageInfo = nm && getPackageJsonInfo(nm.packageDirectory, nm.subModuleName, /*onlyRecordFailures*/ false, state);
- var packageId = packageInfo && packageInfo.packageId;
- return withPackageId(packageId, resolvedFromFile);
+ var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
+ var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined;
+ return withPackageId(packageInfo, resolvedFromFile);
}
}
if (!onlyRecordFailures) {
@@ -27066,11 +27162,10 @@ var ts;
* (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.)
*
* packageDirectory is the directory of the package itself.
- * subModuleName is the path within the package.
- * For `blah/node_modules/foo/index.d.ts` this is { packageDirectory: "foo", subModuleName: "index.d.ts" }. (Part before "/node_modules/" is ignored.)
- * For `/node_modules/foo/bar.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
- * For `/node_modules/@types/foo/bar/index.d.ts` this is { packageDirectory: "@types/foo", subModuleName: "bar/index.d.ts" }.
- * For `/node_modules/foo/bar/index.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
+ * For `blah/node_modules/foo/index.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/foo/bar.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo"
+ * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo"
*/
function parseNodeModuleFromPath(resolved) {
var path = ts.normalizePath(resolved.path);
@@ -27083,26 +27178,12 @@ var ts;
if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) {
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
}
- var packageDirectory = path.slice(0, indexAfterPackageName);
- var subModuleName = ts.removeExtension(path.slice(indexAfterPackageName + 1), resolved.ext) + ".d.ts" /* Dts */;
- return { packageDirectory: packageDirectory, subModuleName: subModuleName };
+ return path.slice(0, indexAfterPackageName);
}
function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
}
- function addExtensionAndIndex(path) {
- if (path === "") {
- return "index.d.ts";
- }
- if (ts.endsWith(path, ".d.ts")) {
- return path;
- }
- if (path === "index" || ts.endsWith(path, "/index")) {
- return path + ".d.ts";
- }
- return path + "/index.d.ts";
- }
function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
}
@@ -27176,52 +27257,22 @@ var ts;
}
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
if (considerPackageJson === void 0) { considerPackageJson = true; }
- var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, "", onlyRecordFailures, state) : undefined;
- var packageId = packageInfo && packageInfo.packageId;
+ var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
var versionPaths = packageInfo && packageInfo.versionPaths;
- return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
+ return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
}
- function getPackageJsonInfo(packageDirectory, subModuleName, onlyRecordFailures, state) {
+ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
var host = state.host, traceEnabled = state.traceEnabled;
var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
if (directoryExists && host.fileExists(packageJsonPath)) {
var packageJsonContent = ts.readJson(packageJsonPath, host);
- if (subModuleName === "") { // looking up the root - need to handle types/typings/main redirects for subModuleName
- var path = readPackageJsonTypesFields(packageJsonContent, packageDirectory, state);
- if (typeof path === "string") {
- subModuleName = addExtensionAndIndex(path.substring(packageDirectory.length + 1));
- }
- else {
- var jsPath = readPackageJsonMainField(packageJsonContent, packageDirectory, state);
- if (typeof jsPath === "string" && jsPath.length > packageDirectory.length) {
- var potentialSubModule_1 = jsPath.substring(packageDirectory.length + 1);
- subModuleName = (ts.forEach(ts.supportedJSExtensions, function (extension) {
- return ts.tryRemoveExtension(potentialSubModule_1, extension);
- }) || potentialSubModule_1) + ".d.ts" /* Dts */;
- }
- else {
- subModuleName = "index.d.ts";
- }
- }
- }
- if (!ts.endsWith(subModuleName, ".d.ts" /* Dts */)) {
- subModuleName = addExtensionAndIndex(subModuleName);
- }
- var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
- var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string"
- ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version }
- : undefined;
if (traceEnabled) {
- if (packageId) {
- trace(host, ts.Diagnostics.Found_package_json_at_0_Package_ID_is_1, packageJsonPath, ts.packageIdToString(packageId));
- }
- else {
- trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
- }
+ trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
}
- return { packageJsonContent: packageJsonContent, packageId: packageId, versionPaths: versionPaths };
+ var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
+ return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
}
else {
if (directoryExists && traceEnabled) {
@@ -27360,37 +27411,31 @@ var ts;
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
- var packageJsonContent;
- var packageId;
- var versionPaths;
- var packageInfo = getPackageJsonInfo(candidate, "", !nodeModulesDirectoryExists, state);
+ var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
if (packageInfo) {
- (packageJsonContent = packageInfo.packageJsonContent, packageId = packageInfo.packageId, versionPaths = packageInfo.versionPaths);
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
if (fromFile) {
return noPackageId(fromFile);
}
- var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, fromDirectory);
+ var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
+ return withPackageId(packageInfo, fromDirectory);
}
var loader = function (extensions, candidate, onlyRecordFailures, state) {
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
- loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, pathAndExtension);
+ loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
+ return withPackageId(packageInfo, pathAndExtension);
};
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
if (rest !== "") { // If "rest" is empty, we just did this search above.
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
// Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings.
- var packageInfo_1 = getPackageJsonInfo(packageDirectory, rest, !nodeModulesDirectoryExists, state);
- if (packageInfo_1)
- (packageId = packageInfo_1.packageId, versionPaths = packageInfo_1.versionPaths);
- if (versionPaths) {
+ packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
+ if (packageInfo && packageInfo.versionPaths) {
if (state.traceEnabled) {
- trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, rest);
+ trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest);
}
var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, versionPaths.paths, loader, !packageDirectoryExists, state);
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
if (fromPaths) {
return fromPaths.value;
}
@@ -29845,7 +29890,7 @@ var ts;
}
break;
default:
- ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer));
+ ts.Debug.failBadSyntaxKind(thisContainer);
}
}
function bindSpecialPropertyDeclaration(node) {
@@ -29903,7 +29948,7 @@ var ts;
// Fix up parent pointers since we're going to use these nodes before we bind into them
node.left.parent = node;
node.right.parent = node;
- if (ts.isIdentifier(lhs.expression) && container === file && isNameOfExportsOrModuleExportsAliasDeclaration(file, lhs.expression)) {
+ if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) {
// This can be an alias for the 'exports' or 'module.exports' names, e.g.
// var util = module.exports;
// util.property = function ...
@@ -30258,20 +30303,29 @@ var ts;
}
}
function isExportsOrModuleExportsOrAlias(sourceFile, node) {
- return ts.isExportsIdentifier(node) ||
- ts.isModuleExportsPropertyAccessExpression(node) ||
- ts.isIdentifier(node) && isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node);
+ var i = 0;
+ var q = [node];
+ while (q.length && i < 100) {
+ i++;
+ node = q.shift();
+ if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) {
+ return true;
+ }
+ else if (ts.isIdentifier(node)) {
+ var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
+ if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
+ var init = symbol.valueDeclaration.initializer;
+ q.push(init);
+ if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) {
+ q.push(init.left);
+ q.push(init.right);
+ }
+ }
+ }
+ }
+ return false;
}
ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
- function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) {
- var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
- return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) &&
- !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer);
- }
- function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) {
- return isExportsOrModuleExportsOrAlias(sourceFile, node) ||
- (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && (isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.left) || isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.right)));
- }
function lookupSymbolForNameWorker(container, name) {
var local = container.locals && container.locals.get(name);
if (local) {
@@ -31411,6 +31465,10 @@ var ts;
node = ts.getParseTreeNode(node);
return node ? getTypeOfNode(node) : errorType;
},
+ getTypeOfAssignmentPattern: function (nodeIn) {
+ var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
+ return node && getTypeOfAssignmentPattern(node) || errorType;
+ },
getPropertySymbolOfDestructuringAssignment: function (locationIn) {
var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
@@ -34511,7 +34569,7 @@ var ts;
context.approximateLength += 6;
return ts.createKeywordTypeNode(137 /* ObjectKeyword */);
}
- if (type.flags & 262144 /* TypeParameter */ && type.isThisType) {
+ if (isThisTypeParameter(type)) {
if (context.flags & 4194304 /* InObjectTypeLiteral */) {
if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
context.encounteredError = true;
@@ -35201,6 +35259,11 @@ var ts;
function lookupTypeParameterNodes(chain, index, context) {
ts.Debug.assert(chain && 0 <= index && index < chain.length);
var symbol = chain[index];
+ var symbolId = "" + getSymbolId(symbol);
+ if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
+ return undefined;
+ }
+ (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
var typeParameterNodes;
if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) {
var parentSymbol = symbol;
@@ -36141,7 +36204,7 @@ var ts;
return type;
}
else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(declaredType, declaration, type);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
}
}
return declaredType;
@@ -36460,7 +36523,7 @@ var ts;
type = getTypeOfEnumMember(symbol);
}
else {
- return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol));
+ return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
}
if (!popTypeResolution()) {
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
@@ -37730,10 +37793,10 @@ var ts;
// Union the result types when more than one signature matches
if (unionSignatures.length > 1) {
var thisParameter = signature.thisParameter;
- if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) {
- // TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do
+ var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
+ if (firstThisParameterOfUnionSignatures) {
var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */);
- thisParameter = createSymbolWithType(signature.thisParameter, thisType);
+ thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
}
s = createUnionSignature(signature, unionSignatures);
s.thisParameter = thisParameter;
@@ -38299,15 +38362,19 @@ var ts;
function getConstraintOfIndexedAccess(type) {
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
}
+ function getSimplifiedTypeOrConstraint(type) {
+ var simplified = getSimplifiedType(type, /*writing*/ false);
+ return simplified !== type ? simplified : getConstraintOfType(type);
+ }
function getConstraintFromIndexedAccess(type) {
- var indexConstraint = getConstraintOfType(type.indexType);
+ var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
if (indexConstraint && indexConstraint !== type.indexType) {
var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
if (indexedAccess) {
return indexedAccess;
}
}
- var objectConstraint = getConstraintOfType(type.objectType);
+ var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
if (objectConstraint && objectConstraint !== type.objectType) {
return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
}
@@ -40296,6 +40363,14 @@ var ts;
types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
return true;
}
+ function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
+ var result = createType(2097152 /* Intersection */);
+ result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
+ result.types = types;
+ result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
+ result.aliasTypeArguments = aliasTypeArguments;
+ return result;
+ }
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
@@ -40333,30 +40408,36 @@ var ts;
if (typeSet.length === 1) {
return typeSet[0];
}
- if (includes & 1048576 /* Union */) {
- if (intersectUnionsOfPrimitiveTypes(typeSet)) {
- // When the intersection creates a reduced set (which might mean that *all* union types have
- // disappeared), we restart the operation to get a new set of combined flags. Once we have
- // reduced we'll never reduce again, so this occurs at most once.
- return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
- }
- // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
- // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
- var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
- var unionType = typeSet[unionIndex_1];
- return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
- }
var id = getTypeListId(typeSet);
- var type = intersectionTypes.get(id);
- if (!type) {
- type = createType(2097152 /* Intersection */);
- intersectionTypes.set(id, type);
- type.objectFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */);
- type.types = typeSet;
- type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
- type.aliasTypeArguments = aliasTypeArguments;
+ var result = intersectionTypes.get(id);
+ if (!result) {
+ if (includes & 1048576 /* Union */) {
+ if (intersectUnionsOfPrimitiveTypes(typeSet)) {
+ // When the intersection creates a reduced set (which might mean that *all* union types have
+ // disappeared), we restart the operation to get a new set of combined flags. Once we have
+ // reduced we'll never reduce again, so this occurs at most once.
+ result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ else {
+ // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
+ // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
+ // If the estimated size of the resulting union type exceeds 100000 constituents, report an error.
+ var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 /* Union */ ? t.types.length : 1); }, 1);
+ if (size >= 100000) {
+ error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
+ return errorType;
+ }
+ var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
+ var unionType = typeSet[unionIndex_1];
+ result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
+ }
+ }
+ else {
+ result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ intersectionTypes.set(id, result);
}
- return type;
+ return result;
}
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
@@ -40489,7 +40570,7 @@ var ts;
}
return false;
}
- function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, accessNode, accessFlags) {
+ function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined;
var propName = isTypeUsableAsPropertyName(indexType) ?
getPropertyNameFromType(indexType) :
@@ -40527,6 +40608,7 @@ var ts;
error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
}
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */));
return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
}
}
@@ -40548,13 +40630,7 @@ var ts;
error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
return indexInfo.type;
}
- if (indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
- if (accessExpression) {
- error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
- return indexInfo.type;
- }
- return undefined;
- }
+ errorIfWritingToReadonlyIndex(indexInfo);
return indexInfo.type;
}
if (indexType.flags & 131072 /* Never */) {
@@ -40567,7 +40643,7 @@ var ts;
if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) {
error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
- else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
+ else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
}
@@ -40587,7 +40663,25 @@ var ts;
error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion_1);
}
else {
- error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType));
+ var errorInfo = void 0;
+ if (indexType.flags & 1024 /* EnumLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 8192 /* UniqueESSymbol */) {
+ var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 128 /* StringLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & 256 /* NumberLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
+ }
+ errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType));
+ diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
}
}
}
@@ -40614,6 +40708,11 @@ var ts;
return indexType;
}
return undefined;
+ function errorIfWritingToReadonlyIndex(indexInfo) {
+ if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
+ error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
+ }
+ }
}
function getIndexNodeForAccessExpression(accessNode) {
return accessNode.kind === 191 /* ElementAccessExpression */
@@ -40630,6 +40729,9 @@ var ts;
function isGenericIndexType(type) {
return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */);
}
+ function isThisTypeParameter(type) {
+ return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
+ }
function getSimplifiedType(type, writing) {
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
@@ -40765,7 +40867,7 @@ var ts;
var wasMissingProp = false;
for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
var t = _a[_i];
- var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, accessNode, accessFlags);
+ var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
if (propType) {
propTypes.push(propType);
}
@@ -40783,7 +40885,7 @@ var ts;
}
return accessFlags & 2 /* Writing */ ? getIntersectionType(propTypes) : getUnionType(propTypes);
}
- return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, accessNode, accessFlags | 4 /* CacheSymbol */);
+ return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */);
}
function getTypeFromIndexedAccessTypeNode(node) {
var links = getNodeLinks(node);
@@ -43329,8 +43431,7 @@ var ts;
}
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
// simplified form of T or, if T doesn't simplify, the constraint of T.
- var simplified = getSimplifiedType(target.type, /*writing*/ false);
- var constraint = simplified !== target.type ? simplified : getConstraintOfType(target.type);
+ var constraint = getSimplifiedTypeOrConstraint(target.type);
if (constraint) {
// We require Ternary.True here such that circular constraints don't cause
// false positives. For example, given 'T extends { [K in keyof T]: string }',
@@ -46871,7 +46972,7 @@ var ts;
return !assumeTrue;
}
function narrowByInKeyword(type, literal, assumeTrue) {
- if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) {
+ if (type.flags & (1048576 /* Union */ | 524288 /* Object */) || isThisTypeParameter(type)) {
var propName_1 = ts.escapeLeadingUnderscores(literal.text);
return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
}
@@ -48423,8 +48524,8 @@ var ts;
// For a (non-symbol) computed property, there is no reason to look up the name
// in the type. It will just be "__computed", which does not appear in any
// SymbolTable.
- var symbolName_2 = getSymbolOfNode(element).escapedName;
- var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_2);
+ var symbolName_3 = getSymbolOfNode(element).escapedName;
+ var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
if (propertyType) {
return propertyType;
}
@@ -49899,7 +50000,7 @@ var ts;
return anyType;
}
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
- reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType);
+ reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
}
return errorType;
}
@@ -50264,7 +50365,7 @@ var ts;
}
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
var accessFlags = ts.isAssignmentTarget(node) ?
- 2 /* Writing */ | (isGenericObjectType(objectType) ? 1 /* NoIndexSignatures */ : 0) :
+ 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) :
0 /* None */;
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
return checkIndexedAccessIndexType(indexedAccessType, node);
@@ -52844,15 +52945,16 @@ var ts;
if (strictNullChecks && properties.length === 0) {
return checkNonNullType(sourceType, node);
}
- for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
- var p = properties_4[_i];
- checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis);
+ for (var i = 0; i < properties.length; i++) {
+ checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
}
return sourceType;
}
/** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */
- function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) {
+ function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
if (rightIsThis === void 0) { rightIsThis = false; }
+ var properties = node.properties;
+ var property = properties[propertyIndex];
if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) {
var name = property.name;
var exprType = getLiteralTypeFromPropertyName(name);
@@ -52869,18 +52971,26 @@ var ts;
return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
}
else if (property.kind === 278 /* SpreadAssignment */) {
- if (languageVersion < 8 /* ESNext */) {
- checkExternalEmitHelpers(property, 4 /* Rest */);
+ if (propertyIndex < properties.length - 1) {
+ error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
}
- var nonRestNames = [];
- if (allProperties) {
- for (var i = 0; i < allProperties.length - 1; i++) {
- nonRestNames.push(allProperties[i].name);
+ else {
+ if (languageVersion < 8 /* ESNext */) {
+ checkExternalEmitHelpers(property, 4 /* Rest */);
+ }
+ var nonRestNames = [];
+ if (allProperties) {
+ for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
+ var otherProperty = allProperties_1[_i];
+ if (!ts.isSpreadAssignment(otherProperty)) {
+ nonRestNames.push(otherProperty.name);
+ }
+ }
}
+ var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
+ checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
+ return checkDestructuringAssignment(property.expression, type);
}
- var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
- checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
- return checkDestructuringAssignment(property.expression, type);
}
else {
error(property, ts.Diagnostics.Property_assignment_expected);
@@ -54819,7 +54929,7 @@ var ts;
case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591
return 1 /* ExportValue */;
default:
- return ts.Debug.fail(ts.Debug.showSyntaxKind(d));
+ return ts.Debug.failBadSyntaxKind(d);
}
}
}
@@ -55984,7 +56094,7 @@ var ts;
if (type !== errorType && declarationType !== errorType &&
!isTypeIdenticalTo(type, declarationType) &&
!(symbol.flags & 67108864 /* Assignment */)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
}
if (node.initializer) {
checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined);
@@ -56003,12 +56113,16 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) {
+ function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */
? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
: ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
- error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType));
+ var declName = ts.declarationNameToString(nextDeclarationName);
+ var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
+ if (firstDeclaration) {
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
+ }
}
function areDeclarationFlagsIdentical(left, right) {
if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) ||
@@ -57149,8 +57263,8 @@ var ts;
for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
var base = baseTypes_2[_i];
var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
- for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) {
- var prop = properties_5[_a];
+ for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) {
+ var prop = properties_4[_a];
var existing = seen.get(prop.escapedName);
if (!existing) {
seen.set(prop.escapedName, { prop: prop, containingType: base });
@@ -58766,7 +58880,7 @@ var ts;
// }
// [ a ] from
// [a] = [ some array ...]
- function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) {
+ function getTypeOfAssignmentPattern(expr) {
ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */);
// If this is from "for of"
// for ( { a } of elems) {
@@ -58784,15 +58898,17 @@ var ts;
// If this is from nested object binding pattern
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
if (expr.parent.kind === 276 /* PropertyAssignment */) {
- var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent);
- return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217
+ var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
+ var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType;
+ var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent);
+ return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex);
}
// Array literal assignment - array destructuring pattern
- ts.Debug.assert(expr.parent.kind === 188 /* ArrayLiteralExpression */);
+ var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
// [{ property1: p1, property2 }] = elems;
- var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent);
- var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
- return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); // TODO: GH#18217
+ var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
+ var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
+ return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
}
// Gets the property symbol corresponding to the property in destructuring assignment
// 'property1' from
@@ -58802,7 +58918,7 @@ var ts;
// [a] = [ property1, property2 ]
function getPropertySymbolOfDestructuringAssignment(location) {
// Get the type of the object or array literal and then look for property of given name in the type
- var typeOfObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(location.parent.parent);
+ var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
}
function getRegularTypeOfExpression(expr) {
@@ -58968,12 +59084,16 @@ var ts;
}
return undefined;
}
+ function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
+ return ts.isBindingElement(symbol.valueDeclaration)
+ && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */;
+ }
function isSymbolOfDeclarationWithCollidingName(symbol) {
if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) {
var links = getSymbolLinks(symbol);
if (links.isDeclarationWithCollidingName === undefined) {
var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
- if (ts.isStatementWithLocals(container)) {
+ if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) {
// redeclaration - always should be renamed
@@ -64456,7 +64576,7 @@ var ts;
function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
if (property === firstAccessor) {
- var properties_6 = [];
+ var properties_5 = [];
if (getAccessor) {
var getterFunction = ts.createFunctionExpression(getAccessor.modifiers,
/*asteriskToken*/ undefined,
@@ -64467,7 +64587,7 @@ var ts;
ts.setTextRange(getterFunction, getAccessor);
ts.setOriginalNode(getterFunction, getAccessor);
var getter = ts.createPropertyAssignment("get", getterFunction);
- properties_6.push(getter);
+ properties_5.push(getter);
}
if (setAccessor) {
var setterFunction = ts.createFunctionExpression(setAccessor.modifiers,
@@ -64479,15 +64599,15 @@ var ts;
ts.setTextRange(setterFunction, setAccessor);
ts.setOriginalNode(setterFunction, setAccessor);
var setter = ts.createPropertyAssignment("set", setterFunction);
- properties_6.push(setter);
+ properties_5.push(setter);
}
- properties_6.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
- properties_6.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"),
/*typeArguments*/ undefined, [
receiver,
createExpressionForPropertyName(property.name),
- ts.createObjectLiteral(properties_6, multiLine)
+ ts.createObjectLiteral(properties_5, multiLine)
]),
/*location*/ firstAccessor);
return ts.aggregateTransformFlags(expression);
@@ -66466,7 +66586,7 @@ var ts;
* @param nodes The NodeArray.
*/
function liftToBlock(nodes) {
- Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
+ ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
}
ts.liftToBlock = liftToBlock;
@@ -66531,73 +66651,6 @@ var ts;
function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
}
- var Debug;
- (function (Debug) {
- var isDebugInfoEnabled = false;
- function failBadSyntaxKind(node, message) {
- return Debug.fail((message || "Unexpected node.") + "\r\nNode " + ts.formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
- }
- Debug.failBadSyntaxKind = failBadSyntaxKind;
- Debug.assertEachNode = Debug.shouldAssert(1 /* Normal */)
- ? function (nodes, test, message) { return Debug.assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertEachNode); }
- : ts.noop;
- Debug.assertNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertNode); }
- : ts.noop;
- Debug.assertOptionalNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
- : ts.noop;
- Debug.assertOptionalToken = Debug.shouldAssert(1 /* Normal */)
- ? function (node, kind, message) { return Debug.assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was not a '" + ts.formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
- : ts.noop;
- Debug.assertMissingNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, message) { return Debug.assert(node === undefined, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
- : ts.noop;
- /**
- * Injects debug information into frequently used types.
- */
- function enableDebugInfo() {
- if (isDebugInfoEnabled)
- return;
- // Add additional properties in debug mode to assist with debugging.
- Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatSymbolFlags(this.flags); } }
- });
- Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } },
- __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } },
- __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
- });
- var nodeConstructors = [
- ts.objectAllocator.getNodeConstructor(),
- ts.objectAllocator.getIdentifierConstructor(),
- ts.objectAllocator.getTokenConstructor(),
- ts.objectAllocator.getSourceFileConstructor()
- ];
- for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
- var ctor = nodeConstructors_1[_i];
- if (!ctor.prototype.hasOwnProperty("__debugKind")) {
- Object.defineProperties(ctor.prototype, {
- __debugKind: { get: function () { return ts.formatSyntaxKind(this.kind); } },
- __debugModifierFlags: { get: function () { return ts.formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
- __debugTransformFlags: { get: function () { return ts.formatTransformFlags(this.transformFlags); } },
- __debugEmitFlags: { get: function () { return ts.formatEmitFlags(ts.getEmitFlags(this)); } },
- __debugGetText: {
- value: function (includeTrivia) {
- if (ts.nodeIsSynthesized(this))
- return "";
- var parseNode = ts.getParseTreeNode(this);
- var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
- return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
- }
- }
- });
- }
- }
- isDebugInfoEnabled = true;
- }
- Debug.enableDebugInfo = enableDebugInfo;
- })(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
/* @internal */
var ts;
@@ -68973,8 +69026,8 @@ var ts;
* @param receiver The receiver on which each property should be assigned.
*/
function addInitializedPropertyStatements(statements, properties, receiver) {
- for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
- var property = properties_7[_i];
+ for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) {
+ var property = properties_6[_i];
var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver));
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
ts.setCommentRange(statement, property);
@@ -68990,8 +69043,8 @@ var ts;
*/
function generateInitializedPropertyExpressions(properties, receiver) {
var expressions = [];
- for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
- var property = properties_8[_i];
+ for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
+ var property = properties_7[_i];
var expression = transformInitializedProperty(property, receiver);
ts.startOnNewLine(expression);
ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
@@ -71533,6 +71586,8 @@ var ts;
return visitObjectLiteralExpression(node);
case 205 /* BinaryExpression */:
return visitBinaryExpression(node, noDestructuringValue);
+ case 275 /* CatchClause */:
+ return visitCatchClause(node);
case 238 /* VariableDeclaration */:
return visitVariableDeclaration(node);
case 228 /* ForOfStatement */:
@@ -71669,6 +71724,23 @@ var ts;
}
return ts.visitEachChild(node, visitor, context);
}
+ function visitCatchClause(node) {
+ if (node.variableDeclaration &&
+ ts.isBindingPattern(node.variableDeclaration.name) &&
+ node.variableDeclaration.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) {
+ var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
+ var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*type*/ undefined, name);
+ var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
+ var block = ts.visitNode(node.block, visitor, ts.isBlock);
+ if (ts.some(visitedBindings)) {
+ block = ts.updateBlock(block, [
+ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings)
+ ].concat(block.statements));
+ }
+ return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block);
+ }
+ return ts.visitEachChild(node, visitor, context);
+ }
/**
* Visits a VariableDeclaration node with a binding pattern.
*
@@ -72812,62 +72884,63 @@ var ts;
HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block";
HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement";
HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock";
- HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement";
- HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper";
+ HierarchyFacts[HierarchyFacts["IterationContainer"] = 1024] = "IterationContainer";
+ HierarchyFacts[HierarchyFacts["ForStatement"] = 2048] = "ForStatement";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 4096] = "ForInOrForOfStatement";
+ HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 8192] = "ConstructorWithCapturedSuper";
// NOTE: do not add more ancestor flags without also updating AncestorFactsMask below.
// NOTE: when adding a new ancestor flag, be sure to update the subtree flags below.
//
// Ancestor masks
//
- HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 8191] = "AncestorFactsMask";
+ HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask";
// We are always in *some* kind of block scope, but only specific block-scope containers are
// top-level or Blocks.
HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes";
- HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes";
+ HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 7104] = "BlockScopeExcludes";
// A source file is a top-level block scope.
HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes";
- HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes";
+ HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 8064] = "SourceFileExcludes";
// Functions, methods, and accessors are both new lexical scopes and new block scopes.
HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes";
- HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 8094] = "FunctionExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes";
HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes";
- HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 8086] = "AsyncFunctionBodyExcludes";
+ HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes";
// Arrow functions are lexically scoped to their container, but are new block scopes.
HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes";
- HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 8064] = "ArrowFunctionExcludes";
+ HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 15232] = "ArrowFunctionExcludes";
// Constructors are both new lexical scopes and new block scopes. Constructors are also
// always considered non-static members of a class.
HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes";
- HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 8086] = "ConstructorExcludes";
+ HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes";
// 'do' and 'while' statements are not block scopes. We track that the subtree is contained
// within an IterationStatement to indicate whether the embedded statement is an
// IterationStatementBlock.
- HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes";
+ HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 1280] = "DoOrWhileStatementIncludes";
HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes";
// 'for' statements are new block scopes and have special handling for 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 3328] = "ForStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 5056] = "ForStatementExcludes";
// 'for-in' and 'for-of' statements are new block scopes and have special handling for
// 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 5376] = "ForInOrForOfStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 3008] = "ForInOrForOfStatementExcludes";
// Blocks (other than function bodies) are new block scopes.
HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes";
- HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes";
+ HierarchyFacts[HierarchyFacts["BlockExcludes"] = 6976] = "BlockExcludes";
HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes";
- HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes";
+ HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 7104] = "IterationStatementBlockExcludes";
//
// Subtree facts
//
- HierarchyFacts[HierarchyFacts["NewTarget"] = 8192] = "NewTarget";
- HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 16384] = "CapturedLexicalThis";
+ HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget";
+ HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 32768] = "CapturedLexicalThis";
//
// Subtree masks
//
- HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -8192] = "SubtreeFactsMask";
+ HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask";
HierarchyFacts[HierarchyFacts["ArrowFunctionSubtreeExcludes"] = 0] = "ArrowFunctionSubtreeExcludes";
- HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 24576] = "FunctionSubtreeExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 49152] = "FunctionSubtreeExcludes";
})(HierarchyFacts || (HierarchyFacts = {}));
function transformES2015(context) {
var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
@@ -72916,7 +72989,7 @@ var ts;
*/
function enterSubtree(excludeFacts, includeFacts) {
var ancestorFacts = hierarchyFacts;
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 8191 /* AncestorFactsMask */;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */;
return ancestorFacts;
}
/**
@@ -72927,17 +73000,17 @@ var ts;
* @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated.
*/
function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -8192 /* SubtreeFactsMask */ | ancestorFacts;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts;
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
- return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0
+ return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0
&& node.kind === 231 /* ReturnStatement */
&& !node.expression;
}
function shouldVisitNode(node) {
return (node.transformFlags & 128 /* ContainsES2015 */) !== 0
|| convertedLoopState !== undefined
- || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
+ || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
|| (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node))
|| (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0;
}
@@ -73054,7 +73127,7 @@ var ts;
}
}
function visitSourceFile(node) {
- var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
+ var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
var prologue = [];
var statements = [];
startLexicalEnvironment();
@@ -73081,7 +73154,7 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitCaseBlock(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -73108,7 +73181,7 @@ var ts;
}
function visitThisKeyword(node) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
if (convertedLoopState) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
@@ -73351,7 +73424,7 @@ var ts;
function addConstructor(statements, node, extendsClauseElement) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8086 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
+ var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
var constructor = ts.getFirstConstructorWithBody(node);
var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
var constructorFunction = ts.createFunctionDeclaration(
@@ -73365,7 +73438,7 @@ var ts;
ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */);
}
statements.push(constructorFunction);
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
}
/**
@@ -73458,7 +73531,7 @@ var ts;
}
}
if (superCallExpression) {
- hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */;
+ hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
}
// visit the remaining statements
@@ -73762,7 +73835,7 @@ var ts;
* @param node A node.
*/
function insertCaptureThisForNodeIfNeeded(statements, node) {
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
insertCaptureThisForNode(statements, node, ts.createThis());
return true;
}
@@ -73780,7 +73853,7 @@ var ts;
ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
}
function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
- if (hierarchyFacts & 8192 /* NewTarget */) {
+ if (hierarchyFacts & 16384 /* NewTarget */) {
var newTarget = void 0;
switch (node.kind) {
case 198 /* ArrowFunction */:
@@ -73950,11 +74023,11 @@ var ts;
*/
function visitArrowFunction(node) {
if (node.transformFlags & 2048 /* ContainsLexicalThis */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8064 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
+ var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
var func = ts.createFunctionExpression(
/*modifiers*/ undefined,
/*asteriskToken*/ undefined,
@@ -73964,7 +74037,7 @@ var ts;
ts.setTextRange(func, node);
ts.setOriginalNode(func, node);
ts.setEmitFlags(func, 8 /* CapturesThis */);
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */) {
enableSubstitutionsForCapturedThis();
}
// If an arrow function contains
@@ -73979,16 +74052,16 @@ var ts;
*/
function visitFunctionExpression(node) {
var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */
- ? enterSubtree(8086 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionExpression(node,
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -74003,13 +74076,13 @@ var ts;
function visitFunctionDeclaration(node) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionDeclaration(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name,
@@ -74027,14 +74100,14 @@ var ts;
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */)
- ? enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- if (hierarchyFacts & 8192 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
+ if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
name = ts.getGeneratedNameForNode(node);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -74129,8 +74202,8 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */
- ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
- : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */);
+ ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
+ : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -74313,11 +74386,11 @@ var ts;
&& isDeclaredInLoop
&& (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0);
var emitExplicitInitializer = !emittedAsTopLevel
- && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0
+ && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0
&& (!resolver.isDeclarationWithCollidingName(node)
|| (isDeclaredInLoop
&& !isCapturedInFunction
- && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0));
+ && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0));
return emitExplicitInitializer;
}
/**
@@ -74388,21 +74461,21 @@ var ts;
}
function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
- var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert);
+ var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
}
function visitDoOrWhileStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
}
function visitForStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement);
}
function visitForInStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
}
function visitForOfStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
}
function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
var statements = [];
@@ -74510,7 +74583,7 @@ var ts;
ts.setTextRange(forStatement, node);
return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
}
- function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) {
+ function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined);
var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined);
@@ -74521,9 +74594,13 @@ var ts;
var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []);
hoistVariableDeclaration(errorRecord);
hoistVariableDeclaration(returnMethod);
+ // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration
+ var initializer = ancestorFacts & 1024 /* IterationContainer */
+ ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
+ : values;
var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(
/*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
- ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression),
+ ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, initializer), node.expression),
ts.createVariableDeclaration(result, /*type*/ undefined, next)
]), node.expression), 2097152 /* NoHoisting */),
/*condition*/ ts.createLogicalNot(ts.createPropertyAccess(result, "done")),
@@ -74634,7 +74711,7 @@ var ts;
}
}
}
- function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) {
+ function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
if (!shouldConvertIterationStatement(node)) {
var saveAllowedNonLabeledJumps = void 0;
if (convertedLoopState) {
@@ -74644,7 +74721,7 @@ var ts;
convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */;
}
var result = convert
- ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined)
+ ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts)
: ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
if (convertedLoopState) {
convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
@@ -74669,7 +74746,7 @@ var ts;
var loop;
if (bodyFunction) {
if (convert) {
- loop = convert(node, outermostLabeledStatement, bodyFunction.part);
+ loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
}
else {
var clone_3 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, /*multiLine*/ true));
@@ -75187,7 +75264,7 @@ var ts;
return expression;
}
function visitCatchClause(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated;
ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
if (ts.isBindingPattern(node.variableDeclaration.name)) {
@@ -75235,7 +75312,7 @@ var ts;
ts.Debug.assert(!ts.isComputedPropertyName(node.name));
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var updated;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
@@ -75245,7 +75322,7 @@ var ts;
else {
updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return updated;
}
@@ -75731,7 +75808,7 @@ var ts;
}
function visitMetaProperty(node) {
if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") {
- hierarchyFacts |= 8192 /* NewTarget */;
+ hierarchyFacts |= 16384 /* NewTarget */;
return ts.createFileLevelUniqueName("_newTarget");
}
return node;
@@ -75746,7 +75823,7 @@ var ts;
function onEmitNode(hint, node, emitCallback) {
if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) {
// If we are tracking a captured `this`, keep track of the enclosing function.
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
? 65 /* FunctionIncludes */ | 16 /* CapturesThis */
: 65 /* FunctionIncludes */);
previousOnEmitNode(hint, node, emitCallback);
@@ -87680,6 +87757,8 @@ var ts;
case 159 /* GetAccessor */:
case 160 /* SetAccessor */:
return generateNameForMethodOrAccessor(node);
+ case 150 /* ComputedPropertyName */:
+ return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true);
default:
return makeTempVariableName(0 /* Auto */);
}
@@ -90371,7 +90450,10 @@ var ts;
if (isRedirect) {
inputName = getProjectReferenceRedirect(fileName) || fileName;
}
- if (ts.getNormalizedAbsolutePath(checkedName, currentDirectory) !== ts.getNormalizedAbsolutePath(inputName, currentDirectory)) {
+ // Check if it differs only in drive letters its ok to ignore that error:
+ var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
+ var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory);
+ if (checkedAbsolutePath !== inputAbsolutePath) {
reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd);
}
}
@@ -90907,10 +90989,10 @@ var ts;
if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
}
- var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
+ var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
@@ -93311,11 +93393,11 @@ var ts;
}
function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
var result = ts.createMap();
- var symlinks = ts.mapDefined(files, function (sf) {
- return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) {
+ var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
+ return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
- });
- });
+ })));
+ }));
for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];
@@ -99045,7 +99127,7 @@ var ts;
var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of.
var entries = pathCompletions.map(function (_a) {
var name = _a.name, kind = _a.kind, span = _a.span, extension = _a.extension;
- return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: "0", replacementSpan: span });
+ return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: Completions.SortText.LocationPriority, replacementSpan: span });
});
return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
}
@@ -99648,6 +99730,14 @@ var ts;
(function (ts) {
var Completions;
(function (Completions) {
+ var SortText;
+ (function (SortText) {
+ SortText["LocationPriority"] = "0";
+ SortText["SuggestedClassMembers"] = "1";
+ SortText["GlobalsOrKeywords"] = "2";
+ SortText["AutoImportSuggestions"] = "3";
+ SortText["JavascriptIdentifiers"] = "4";
+ })(SortText = Completions.SortText || (Completions.SortText = {}));
var SymbolOriginInfoKind;
(function (SymbolOriginInfoKind) {
SymbolOriginInfoKind[SymbolOriginInfoKind["ThisType"] = 0] = "ThisType";
@@ -99682,8 +99772,9 @@ var ts;
var typeChecker = program.getTypeChecker();
var compilerOptions = program.getCompilerOptions();
var contextToken = ts.findPrecedingToken(position, sourceFile);
- if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position))
+ if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) {
return undefined;
+ }
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences);
if (stringCompletions) {
return stringCompletions;
@@ -99716,7 +99807,7 @@ var ts;
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries };
}
function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) {
- var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression;
+ var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap;
if (location && location.parent && ts.isJsxClosingElement(location.parent)) {
// In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag,
// instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element.
@@ -99730,20 +99821,20 @@ var ts;
name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"),
kind: "class" /* classElement */,
kindModifiers: undefined,
- sortText: "0",
+ sortText: SortText.LocationPriority,
};
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [entry] };
}
var entries = [];
if (isUncheckedFile(sourceFile, compilerOptions)) {
- var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap);
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217
}
else {
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
return undefined;
}
- getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap);
+ getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
}
if (keywordFilters !== 0 /* None */) {
var entryNames = ts.arrayToSet(entries, function (e) { return e.name; });
@@ -99785,7 +99876,7 @@ var ts;
name: realName,
kind: "warning" /* warning */,
kindModifiers: "",
- sortText: "1"
+ sortText: SortText.JavascriptIdentifiers
});
}
});
@@ -99794,14 +99885,9 @@ var ts;
return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal);
};
function createCompletionEntryForLiteral(literal) {
- return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: "0" };
+ return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
}
- function createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
- var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
- if (!info) {
- return undefined;
- }
- var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
+ function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
var insertText;
var replacementSpan;
if (origin && origin.kind === 0 /* ThisType */) {
@@ -99838,7 +99924,7 @@ var ts;
name: name,
kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol),
- sortText: "0",
+ sortText: sortText,
source: getSourceFromOrigin(origin),
hasAction: trueOrUndefined(!!origin && originIsExport(origin)),
isRecommended: trueOrUndefined(isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker)),
@@ -99856,7 +99942,7 @@ var ts;
function getSourceFromOrigin(origin) {
return origin && originIsExport(origin) ? ts.stripQuotes(origin.moduleSymbol.name) : undefined;
}
- function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap) {
+ function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) {
var start = ts.timestamp();
// Tracks unique names.
// We don't set this for global variables or completions from external module exports, because we can have multiple of those.
@@ -99866,14 +99952,18 @@ var ts;
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
var symbol = symbols_1[_i];
var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined;
- var entry = createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
- if (!entry) {
+ var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
+ if (!info) {
continue;
}
- var name = entry.name;
+ var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
if (uniques.has(name)) {
continue;
}
+ var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
+ if (!entry) {
+ continue;
+ }
// Latter case tests whether this is a global variable.
if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { // TODO: GH#18217
uniques.set(name, true);
@@ -99906,7 +99996,7 @@ var ts;
name: name,
kindModifiers: "" /* none */,
kind: "label" /* label */,
- sortText: "0"
+ sortText: SortText.LocationPriority
});
}
}
@@ -100283,6 +100373,7 @@ var ts;
var keywordFilters = 0 /* None */;
var symbols = [];
var symbolToOriginInfoMap = [];
+ var symbolToSortTextMap = [];
if (isRightOfDot) {
getTypeScriptMemberSymbols();
}
@@ -100328,7 +100419,8 @@ var ts;
recommendedCompletion: recommendedCompletion,
previousToken: previousToken,
isJsxInitializer: isJsxInitializer,
- insideJsDocTagTypeExpression: insideJsDocTagTypeExpression
+ insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
+ symbolToSortTextMap: symbolToSortTextMap
};
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
@@ -100510,14 +100602,22 @@ var ts;
var isTypeOnly = isTypeOnlyCompletion();
var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined");
+ for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
+ var symbol = symbols_2[_i];
+ if (!typeChecker.isArgumentsSymbol(symbol) &&
+ !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords;
+ }
+ }
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) {
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
if (thisType) {
- for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
- var symbol = _a[_i];
+ for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
+ var symbol = _b[_a];
symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ };
symbols.push(symbol);
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers;
}
}
}
@@ -100636,6 +100736,7 @@ var ts;
// So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`.
ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) {
symbols.push(resolvedModuleSymbol);
+ symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions;
symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false };
}
for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) {
@@ -100660,6 +100761,7 @@ var ts;
var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport };
if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) {
symbols.push(symbol);
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions;
symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin;
}
}
@@ -101296,7 +101398,7 @@ var ts;
name: ts.tokenToString(i),
kind: "keyword" /* keyword */,
kindModifiers: "" /* none */,
- sortText: "0"
+ sortText: SortText.GlobalsOrKeywords
});
}
return res;
@@ -102147,7 +102249,7 @@ var ts;
directImports.push(direct);
break;
default:
- ts.Debug.assertNever(direct, "Unexpected import kind: " + ts.Debug.showSyntaxKind(direct));
+ ts.Debug.failBadSyntaxKind(direct, "Unexpected import kind.");
}
}
}
@@ -102490,7 +102592,7 @@ var ts;
var sym = useLhsSymbol ? checker.getSymbolAtLocation(ts.cast(node.left, ts.isPropertyAccessExpression).name) : symbol;
// Better detection for GH#20803
if (sym && !(checker.getMergedSymbol(sym.parent).flags & 1536 /* Module */)) {
- ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.showSymbol(sym) + ", parent is " + ts.Debug.showSymbol(sym.parent));
+ ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.formatSymbol(sym) + ", parent is " + ts.Debug.formatSymbol(sym.parent));
}
return sym && exportInfo(sym, kind);
}
@@ -103190,7 +103292,7 @@ var ts;
if (symbol.flags & 33554432 /* Transient */)
return undefined;
// Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here.
- ts.Debug.fail("Unexpected symbol at " + ts.Debug.showSyntaxKind(node) + ": " + ts.Debug.showSymbol(symbol));
+ ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol));
}
return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent)
? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name)
@@ -103295,8 +103397,8 @@ var ts;
var sourceId = ts.getNodeId(sourceFile);
var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = ts.createMap());
var anyNewSymbols = false;
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
- var sym = symbols_2[_i];
+ for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) {
+ var sym = symbols_3[_i];
anyNewSymbols = ts.addToSeen(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
}
return anyNewSymbols;
@@ -107755,8 +107857,21 @@ var ts;
});
}
function containsPrecedingToken(startingToken, sourceFile, container) {
- var precedingToken = ts.Debug.assertDefined(ts.findPrecedingToken(startingToken.getFullStart(), sourceFile, startingToken.parent, /*excludeJsdoc*/ true));
- return ts.rangeContainsRange(container, precedingToken);
+ var pos = startingToken.getFullStart();
+ // There’s a possibility that `startingToken.parent` contains only `startingToken` and
+ // missing nodes, none of which are valid to be returned by `findPrecedingToken`. In that
+ // case, the preceding token we want is actually higher up the tree—almost definitely the
+ // next parent, but theoretically the situation with missing nodes might be happening on
+ // multiple nested levels.
+ var currentParent = startingToken.parent;
+ while (currentParent) {
+ var precedingToken = ts.findPrecedingToken(pos, sourceFile, currentParent, /*excludeJsdoc*/ true);
+ if (precedingToken) {
+ return ts.rangeContainsRange(container, precedingToken);
+ }
+ currentParent = currentParent.parent;
+ }
+ return ts.Debug.fail("Could not find preceding token");
}
function getArgumentInfoForCompletions(node, position, sourceFile) {
var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile);
@@ -108046,7 +108161,7 @@ var ts;
var _loop_7 = function (n) {
// If the node is not a subspan of its parent, this is a big problem.
// There have been crashes that might be caused by this violation.
- ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); });
+ ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); });
var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker);
if (argumentInfo) {
return { value: argumentInfo };
@@ -113112,11 +113227,11 @@ var ts;
function makeChange(changeTracker, sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
if (!ts.isIdentifier(token)) {
- return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.formatSyntaxKind(token.kind));
+ return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.Debug.formatSyntaxKind(token.kind));
}
var param = token.parent;
if (!ts.isParameter(param)) {
- return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.formatSyntaxKind(token.kind));
+ return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.Debug.formatSyntaxKind(token.kind));
}
var i = param.parent.parameters.indexOf(param);
ts.Debug.assert(!param.type, "Tried to add a parameter name to a parameter that already had one.");
@@ -121252,7 +121367,7 @@ var ts;
var textPos = ts.scanner.getTextPos();
if (textPos <= end) {
if (token === 73 /* Identifier */) {
- ts.Debug.fail("Did not expect " + ts.Debug.showSyntaxKind(parent) + " to have an Identifier in its trivia");
+ ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia");
}
nodes.push(createNode(token, pos, textPos, parent));
}
@@ -125546,13 +125661,13 @@ var ts;
server.updateProjectIfDirty(this);
return hasOneOrMoreJsAndNoTsFiles(this);
};
- Project.resolveModule = function (moduleName, initialDir, host, log) {
+ Project.resolveModule = function (moduleName, initialDir, host, log, logErrors) {
var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules")));
log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
var result = host.require(resolvedPath, moduleName); // TODO: GH#18217
if (result.error) {
var err = result.error.stack || result.error.message || JSON.stringify(result.error);
- log("Failed to load module '" + moduleName + "': " + err);
+ (logErrors || log)("Failed to load module '" + moduleName + "' from " + resolvedPath + ": " + err);
return undefined;
}
return result.module;
@@ -126310,11 +126425,11 @@ var ts;
Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
var _this = this;
this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
- var log = function (message) {
- _this.projectService.logger.info(message);
- };
+ var log = function (message) { return _this.projectService.logger.info(message); };
+ var errorLogs;
+ var logError = function (message) { (errorLogs || (errorLogs = [])).push(message); };
var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
- return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log);
+ return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
});
if (resolvedModule) {
var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
@@ -126327,6 +126442,7 @@ var ts;
this.enableProxy(resolvedModule, pluginConfigEntry);
}
else {
+ ts.forEach(errorLogs, log);
this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
}
};
diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts
index f70916a882be6..58ccd42344b00 100644
--- a/lib/typescript.d.ts
+++ b/lib/typescript.d.ts
@@ -1969,6 +1969,7 @@ declare namespace ts {
*/
getExportSymbolOfSymbol(symbol: Symbol): Symbol;
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
+ getTypeOfAssignmentPattern(pattern: AssignmentPattern): Type;
getTypeAtLocation(node: Node): Type;
getTypeFromTypeNode(node: TypeNode): Type;
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
diff --git a/lib/typescript.js b/lib/typescript.js
index 97393be7cf53d..6ccbd71858bf5 100644
--- a/lib/typescript.js
+++ b/lib/typescript.js
@@ -75,7 +75,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.5";
/** The version of the TypeScript compiler release */
- ts.version = ts.versionMajorMinor + ".0-rc";
+ ts.version = ts.versionMajorMinor + ".1";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@@ -315,7 +315,7 @@ var ts;
ts.firstDefinedIterator = firstDefinedIterator;
function zipWith(arrayA, arrayB, callback) {
var result = [];
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
for (var i = 0; i < arrayA.length; i++) {
result.push(callback(arrayA[i], arrayB[i], i));
}
@@ -323,7 +323,7 @@ var ts;
}
ts.zipWith = zipWith;
function zipToIterator(arrayA, arrayB) {
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
var i = 0;
return {
next: function () {
@@ -337,7 +337,7 @@ var ts;
}
ts.zipToIterator = zipToIterator;
function zipToMap(keys, values) {
- Debug.assert(keys.length === values.length);
+ ts.Debug.assert(keys.length === values.length);
var map = createMap();
for (var i = 0; i < keys.length; ++i) {
map.set(keys[i], values[i]);
@@ -411,7 +411,7 @@ var ts;
return result;
}
}
- return Debug.fail();
+ return ts.Debug.fail();
}
ts.findMap = findMap;
function contains(array, value, equalityComparer) {
@@ -841,7 +841,7 @@ var ts;
continue;
case -1 /* LessThan */:
// If `array` is sorted, `next` should **never** be less than `last`.
- return Debug.fail("Array is unsorted.");
+ return ts.Debug.fail("Array is unsorted.");
}
deduplicated.push(last = next);
}
@@ -908,13 +908,13 @@ var ts;
loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
if (offsetB > 0) {
// Ensure `arrayB` is properly sorted.
- Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
}
loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
if (offsetA > startA) {
// Ensure `arrayA` is properly sorted. We only need to perform this check if
// `offsetA` has changed since we entered the loop.
- Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
}
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
case -1 /* LessThan */:
@@ -1084,7 +1084,7 @@ var ts;
}
ts.firstOrUndefined = firstOrUndefined;
function first(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[0];
}
ts.first = first;
@@ -1096,7 +1096,7 @@ var ts;
}
ts.lastOrUndefined = lastOrUndefined;
function last(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[array.length - 1];
}
ts.last = last;
@@ -1421,7 +1421,7 @@ var ts;
function cast(value, test) {
if (value !== undefined && test(value))
return value;
- return Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + Debug.getFunctionName(test) + "'.");
+ return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
}
ts.cast = cast;
/** Does nothing. */
@@ -1490,92 +1490,6 @@ var ts;
AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive";
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
})(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {}));
- var Debug;
- (function (Debug) {
- Debug.currentAssertionLevel = 0 /* None */;
- Debug.isDebugging = false;
- function shouldAssert(level) {
- return Debug.currentAssertionLevel >= level;
- }
- Debug.shouldAssert = shouldAssert;
- function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
- if (!expression) {
- if (verboseDebugInfo) {
- message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
- }
- fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
- }
- }
- Debug.assert = assert;
- function assertEqual(a, b, msg, msg2) {
- if (a !== b) {
- var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
- fail("Expected " + a + " === " + b + ". " + message);
- }
- }
- Debug.assertEqual = assertEqual;
- function assertLessThan(a, b, msg) {
- if (a >= b) {
- fail("Expected " + a + " < " + b + ". " + (msg || ""));
- }
- }
- Debug.assertLessThan = assertLessThan;
- function assertLessThanOrEqual(a, b) {
- if (a > b) {
- fail("Expected " + a + " <= " + b);
- }
- }
- Debug.assertLessThanOrEqual = assertLessThanOrEqual;
- function assertGreaterThanOrEqual(a, b) {
- if (a < b) {
- fail("Expected " + a + " >= " + b);
- }
- }
- Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
- function fail(message, stackCrawlMark) {
- debugger;
- var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
- if (Error.captureStackTrace) {
- Error.captureStackTrace(e, stackCrawlMark || fail);
- }
- throw e;
- }
- Debug.fail = fail;
- function assertDefined(value, message) {
- if (value === undefined || value === null)
- return fail(message);
- return value;
- }
- Debug.assertDefined = assertDefined;
- function assertEachDefined(value, message) {
- for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
- var v = value_1[_i];
- assertDefined(v, message);
- }
- return value;
- }
- Debug.assertEachDefined = assertEachDefined;
- function assertNever(member, message, stackCrawlMark) {
- if (message === void 0) { message = "Illegal value:"; }
- var detail = typeof member === "object" && "kind" in member && "pos" in member ? "SyntaxKind: " + Debug.showSyntaxKind(member) : JSON.stringify(member);
- return fail(message + " " + detail, stackCrawlMark || assertNever);
- }
- Debug.assertNever = assertNever;
- function getFunctionName(func) {
- if (typeof func !== "function") {
- return "";
- }
- else if (func.hasOwnProperty("name")) {
- return func.name;
- }
- else {
- var text = Function.prototype.toString.call(func);
- var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
- return match ? match[1] : "";
- }
- }
- Debug.getFunctionName = getFunctionName;
- })(Debug = ts.Debug || (ts.Debug = {}));
function equateValues(a, b) {
return a === b;
}
@@ -1832,7 +1746,7 @@ var ts;
bestCandidate = candidate;
}
else {
- Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
+ ts.Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
bestDistance = distance;
bestCandidate = candidate;
}
@@ -1976,7 +1890,7 @@ var ts;
* E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar"
*/
function matchedText(pattern, candidate) {
- Debug.assert(isPatternMatch(pattern, candidate));
+ ts.Debug.assert(isPatternMatch(pattern, candidate));
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
}
ts.matchedText = matchedText;
@@ -2095,6 +2009,242 @@ var ts;
}
}
})(ts || (ts = {}));
+/* @internal */
+var ts;
+(function (ts) {
+ var Debug;
+ (function (Debug) {
+ Debug.currentAssertionLevel = 0 /* None */;
+ Debug.isDebugging = false;
+ function shouldAssert(level) {
+ return Debug.currentAssertionLevel >= level;
+ }
+ Debug.shouldAssert = shouldAssert;
+ function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
+ if (!expression) {
+ if (verboseDebugInfo) {
+ message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
+ }
+ fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
+ }
+ }
+ Debug.assert = assert;
+ function assertEqual(a, b, msg, msg2) {
+ if (a !== b) {
+ var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
+ fail("Expected " + a + " === " + b + ". " + message);
+ }
+ }
+ Debug.assertEqual = assertEqual;
+ function assertLessThan(a, b, msg) {
+ if (a >= b) {
+ fail("Expected " + a + " < " + b + ". " + (msg || ""));
+ }
+ }
+ Debug.assertLessThan = assertLessThan;
+ function assertLessThanOrEqual(a, b) {
+ if (a > b) {
+ fail("Expected " + a + " <= " + b);
+ }
+ }
+ Debug.assertLessThanOrEqual = assertLessThanOrEqual;
+ function assertGreaterThanOrEqual(a, b) {
+ if (a < b) {
+ fail("Expected " + a + " >= " + b);
+ }
+ }
+ Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
+ function fail(message, stackCrawlMark) {
+ debugger;
+ var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(e, stackCrawlMark || fail);
+ }
+ throw e;
+ }
+ Debug.fail = fail;
+ function assertDefined(value, message) {
+ if (value === undefined || value === null)
+ return fail(message);
+ return value;
+ }
+ Debug.assertDefined = assertDefined;
+ function assertEachDefined(value, message) {
+ for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
+ var v = value_1[_i];
+ assertDefined(v, message);
+ }
+ return value;
+ }
+ Debug.assertEachDefined = assertEachDefined;
+ function assertNever(member, message, stackCrawlMark) {
+ if (message === void 0) { message = "Illegal value:"; }
+ var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
+ return fail(message + " " + detail, stackCrawlMark || assertNever);
+ }
+ Debug.assertNever = assertNever;
+ function getFunctionName(func) {
+ if (typeof func !== "function") {
+ return "";
+ }
+ else if (func.hasOwnProperty("name")) {
+ return func.name;
+ }
+ else {
+ var text = Function.prototype.toString.call(func);
+ var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
+ return match ? match[1] : "";
+ }
+ }
+ Debug.getFunctionName = getFunctionName;
+ function formatSymbol(symbol) {
+ return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
+ }
+ Debug.formatSymbol = formatSymbol;
+ /**
+ * Formats an enum value as a string for debugging and debug assertions.
+ */
+ function formatEnum(value, enumObject, isFlags) {
+ if (value === void 0) { value = 0; }
+ var members = getEnumMembers(enumObject);
+ if (value === 0) {
+ return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
+ }
+ if (isFlags) {
+ var result = "";
+ var remainingFlags = value;
+ for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
+ var _a = members[i], enumValue = _a[0], enumName = _a[1];
+ if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
+ remainingFlags &= ~enumValue;
+ result = "" + enumName + (result ? "|" : "") + result;
+ }
+ }
+ if (remainingFlags === 0) {
+ return result;
+ }
+ }
+ else {
+ for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
+ var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
+ if (enumValue === value) {
+ return enumName;
+ }
+ }
+ }
+ return value.toString();
+ }
+ Debug.formatEnum = formatEnum;
+ function getEnumMembers(enumObject) {
+ var result = [];
+ for (var name in enumObject) {
+ var value = enumObject[name];
+ if (typeof value === "number") {
+ result.push([value, name]);
+ }
+ }
+ return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
+ }
+ function formatSyntaxKind(kind) {
+ return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
+ }
+ Debug.formatSyntaxKind = formatSyntaxKind;
+ function formatNodeFlags(flags) {
+ return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
+ }
+ Debug.formatNodeFlags = formatNodeFlags;
+ function formatModifierFlags(flags) {
+ return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
+ }
+ Debug.formatModifierFlags = formatModifierFlags;
+ function formatTransformFlags(flags) {
+ return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
+ }
+ Debug.formatTransformFlags = formatTransformFlags;
+ function formatEmitFlags(flags) {
+ return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
+ }
+ Debug.formatEmitFlags = formatEmitFlags;
+ function formatSymbolFlags(flags) {
+ return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
+ }
+ Debug.formatSymbolFlags = formatSymbolFlags;
+ function formatTypeFlags(flags) {
+ return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
+ }
+ Debug.formatTypeFlags = formatTypeFlags;
+ function formatObjectFlags(flags) {
+ return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
+ }
+ Debug.formatObjectFlags = formatObjectFlags;
+ function failBadSyntaxKind(node, message) {
+ return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
+ }
+ Debug.failBadSyntaxKind = failBadSyntaxKind;
+ Debug.assertEachNode = shouldAssert(1 /* Normal */)
+ ? function (nodes, test, message) { return assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertEachNode); }
+ : ts.noop;
+ Debug.assertNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); }
+ : ts.noop;
+ Debug.assertOptionalNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
+ : ts.noop;
+ Debug.assertOptionalToken = shouldAssert(1 /* Normal */)
+ ? function (node, kind, message) { return assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
+ : ts.noop;
+ Debug.assertMissingNode = shouldAssert(1 /* Normal */)
+ ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
+ : ts.noop;
+ var isDebugInfoEnabled = false;
+ /**
+ * Injects debug information into frequently used types.
+ */
+ function enableDebugInfo() {
+ if (isDebugInfoEnabled)
+ return;
+ // Add additional properties in debug mode to assist with debugging.
+ Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
+ __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
+ });
+ Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
+ __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
+ __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } },
+ __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
+ });
+ var nodeConstructors = [
+ ts.objectAllocator.getNodeConstructor(),
+ ts.objectAllocator.getIdentifierConstructor(),
+ ts.objectAllocator.getTokenConstructor(),
+ ts.objectAllocator.getSourceFileConstructor()
+ ];
+ for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
+ var ctor = nodeConstructors_1[_i];
+ if (!ctor.prototype.hasOwnProperty("__debugKind")) {
+ Object.defineProperties(ctor.prototype, {
+ __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
+ __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
+ __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
+ __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
+ __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
+ __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
+ __debugGetText: {
+ value: function (includeTrivia) {
+ if (ts.nodeIsSynthesized(this))
+ return "";
+ var parseNode = ts.getParseTreeNode(this);
+ var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
+ return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
+ }
+ }
+ });
+ }
+ }
+ isDebugInfoEnabled = true;
+ }
+ Debug.enableDebugInfo = enableDebugInfo;
+ })(Debug = ts.Debug || (ts.Debug = {}));
+})(ts || (ts = {}));
/*@internal*/
var ts;
(function (ts) {
@@ -5323,7 +5473,7 @@ var ts;
Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."),
Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
- Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", "Cannot compile namespaces when the '--isolatedModules' flag is provided."),
+ All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."),
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."),
A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
@@ -6110,7 +6260,6 @@ var ts;
Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."),
Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
Multiple_consecutive_numeric_separators_are_not_permitted: diag(6189, ts.DiagnosticCategory.Error, "Multiple_consecutive_numeric_separators_are_not_permitted_6189", "Multiple consecutive numeric separators are not permitted."),
- Found_package_json_at_0_Package_ID_is_1: diag(6190, ts.DiagnosticCategory.Message, "Found_package_json_at_0_Package_ID_is_1_6190", "Found 'package.json' at '{0}'. Package ID is '{1}'."),
Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: diag(6191, ts.DiagnosticCategory.Message, "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191", "Whether to keep outdated console output in watch mode instead of clearing the screen."),
All_imports_in_import_declaration_are_unused: diag(6192, ts.DiagnosticCategory.Error, "All_imports_in_import_declaration_are_unused_6192", "All imports in import declaration are unused.", /*reportsUnnecessary*/ true),
Found_1_error_Watching_for_file_changes: diag(6193, ts.DiagnosticCategory.Message, "Found_1_error_Watching_for_file_changes_6193", "Found 1 error. Watching for file changes."),
@@ -6137,6 +6286,9 @@ var ts;
Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."),
Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
+ Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"),
+ Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"),
+ package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."),
Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
@@ -6226,6 +6378,8 @@ var ts;
_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."),
Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1: diag(7051, ts.DiagnosticCategory.Error, "Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1_7051", "Parameter has a name but no type. Did you mean '{0}: {1}'?"),
Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1: diag(7052, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1_7052", "Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}' ?"),
+ Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: diag(7053, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053", "Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'."),
+ No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1: diag(7054, ts.DiagnosticCategory.Error, "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054", "No index signature with a parameter of type '{0}' was found on type '{1}'."),
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."),
@@ -10299,7 +10453,7 @@ var ts;
}
ts.isFunctionSymbol = isFunctionSymbol;
function importFromModuleSpecifier(node) {
- return tryGetImportFromModuleSpecifier(node) || ts.Debug.fail(ts.Debug.showSyntaxKind(node.parent));
+ return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
}
ts.importFromModuleSpecifier = importFromModuleSpecifier;
function tryGetImportFromModuleSpecifier(node) {
@@ -12254,77 +12408,6 @@ var ts;
return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
- /**
- * Formats an enum value as a string for debugging and debug assertions.
- */
- function formatEnum(value, enumObject, isFlags) {
- if (value === void 0) { value = 0; }
- var members = getEnumMembers(enumObject);
- if (value === 0) {
- return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
- }
- if (isFlags) {
- var result = "";
- var remainingFlags = value;
- for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
- var _a = members[i], enumValue = _a[0], enumName = _a[1];
- if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
- remainingFlags &= ~enumValue;
- result = "" + enumName + (result ? ", " : "") + result;
- }
- }
- if (remainingFlags === 0) {
- return result;
- }
- }
- else {
- for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
- var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
- if (enumValue === value) {
- return enumName;
- }
- }
- }
- return value.toString();
- }
- function getEnumMembers(enumObject) {
- var result = [];
- for (var name in enumObject) {
- var value = enumObject[name];
- if (typeof value === "number") {
- result.push([value, name]);
- }
- }
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
- }
- function formatSyntaxKind(kind) {
- return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
- }
- ts.formatSyntaxKind = formatSyntaxKind;
- function formatModifierFlags(flags) {
- return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
- }
- ts.formatModifierFlags = formatModifierFlags;
- function formatTransformFlags(flags) {
- return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
- }
- ts.formatTransformFlags = formatTransformFlags;
- function formatEmitFlags(flags) {
- return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
- }
- ts.formatEmitFlags = formatEmitFlags;
- function formatSymbolFlags(flags) {
- return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
- }
- ts.formatSymbolFlags = formatSymbolFlags;
- function formatTypeFlags(flags) {
- return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
- }
- ts.formatTypeFlags = formatTypeFlags;
- function formatObjectFlags(flags) {
- return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
- }
- ts.formatObjectFlags = formatObjectFlags;
/**
* Creates a new TextRange from the provided pos and end.
*
@@ -15518,6 +15601,15 @@ var ts;
return root + pathComponents.slice(1).join(ts.directorySeparator);
}
ts.getPathFromPathComponents = getPathFromPathComponents;
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
+ }
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
+ function getPathWithoutRoot(pathComponents) {
+ if (pathComponents.length === 0)
+ return "";
+ return pathComponents.slice(1).join(ts.directorySeparator);
+ }
})(ts || (ts = {}));
/* @internal */
(function (ts) {
@@ -15548,7 +15640,7 @@ var ts;
}
ts.getRelativePathFromFile = getRelativePathFromFile;
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
- Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
+ ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
@@ -16192,32 +16284,9 @@ var ts;
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
}
ts.changeAnyExtension = changeAnyExtension;
- var Debug;
- (function (Debug) {
- function showSymbol(symbol) {
- var symbolFlags = ts.SymbolFlags;
- return "{ flags: " + (symbolFlags ? showFlags(symbol.flags, symbolFlags) : symbol.flags) + "; declarations: " + ts.map(symbol.declarations, showSyntaxKind) + " }";
- }
- Debug.showSymbol = showSymbol;
- function showFlags(flags, flagsEnum) {
- var out = [];
- for (var pow = 0; pow <= 30; pow++) {
- var n = 1 << pow;
- if (flags & n) {
- out.push(flagsEnum[n]);
- }
- }
- return out.join("|");
- }
- function showSyntaxKind(node) {
- var syntaxKind = ts.SyntaxKind;
- return syntaxKind ? syntaxKind[node.kind] : node.kind.toString();
- }
- Debug.showSyntaxKind = showSyntaxKind;
- })(Debug = ts.Debug || (ts.Debug = {}));
function tryParsePattern(pattern) {
// This should be verified outside of here and a proper error thrown.
- Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
+ ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
var indexOfStar = pattern.indexOf("*");
return indexOfStar === -1 ? undefined : {
prefix: pattern.substr(0, indexOfStar),
@@ -16246,7 +16315,7 @@ var ts;
*/
function extensionFromPath(path) {
var ext = tryGetExtensionFromPath(path);
- return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension.");
+ return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
}
ts.extensionFromPath = extensionFromPath;
function isAnySupportedFileExtension(path) {
@@ -16318,7 +16387,7 @@ var ts;
ts.matchPatternOrExact = matchPatternOrExact;
function sliceAfter(arr, value) {
var index = arr.indexOf(value);
- Debug.assert(index !== -1);
+ ts.Debug.assert(index !== -1);
return arr.slice(index);
}
ts.sliceAfter = sliceAfter;
@@ -16336,7 +16405,7 @@ var ts;
}
ts.addRelatedInfo = addRelatedInfo;
function minAndMax(arr, getValue) {
- Debug.assert(arr.length !== 0);
+ ts.Debug.assert(arr.length !== 0);
var min = getValue(arr[0]);
var max = min;
for (var i = 1; i < arr.length; i++) {
@@ -25732,7 +25801,7 @@ var ts;
if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) {
extendedConfigPath = extendedConfigPath + ".json";
if (!host.fileExists(extendedConfigPath)) {
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
}
@@ -25743,7 +25812,7 @@ var ts;
if (resolved.resolvedModule) {
return resolved.resolvedModule.resolvedFileName;
}
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
@@ -26258,11 +26327,22 @@ var ts;
return !!compilerOptions.traceResolution && host.trace !== undefined;
}
ts.isTraceEnabled = isTraceEnabled;
- function withPackageId(packageId, r) {
+ function withPackageId(packageInfo, r) {
+ var packageId;
+ if (r && packageInfo) {
+ var packageJsonContent = packageInfo.packageJsonContent;
+ if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
+ packageId = {
+ name: packageJsonContent.name,
+ subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
+ version: packageJsonContent.version
+ };
+ }
+ }
return r && { path: r.path, extension: r.ext, packageId: packageId };
}
function noPackageId(r) {
- return withPackageId(/*packageId*/ undefined, r);
+ return withPackageId(/*packageInfo*/ undefined, r);
}
function removeIgnoredPackageId(r) {
if (r) {
@@ -26314,8 +26394,15 @@ var ts;
}
function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
- if (fileName === undefined)
+ if (fileName === undefined) {
+ return;
+ }
+ if (!fileName) {
+ if (state.traceEnabled) {
+ trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
+ }
return;
+ }
var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
@@ -26468,7 +26555,12 @@ var ts;
var fileName = resolved.fileName, packageId = resolved.packageId;
var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
if (traceEnabled) {
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ if (packageId) {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary);
+ }
+ else {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ }
}
resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
}
@@ -26756,7 +26848,12 @@ var ts;
}
if (traceEnabled) {
if (result.resolvedModule) {
- trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ if (result.resolvedModule.packageId) {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2, moduleName, result.resolvedModule.resolvedFileName, ts.packageIdToString(result.resolvedModule.packageId));
+ }
+ else {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ }
}
else {
trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
@@ -27026,10 +27123,9 @@ var ts;
}
var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
if (resolvedFromFile) {
- var nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
- var packageInfo = nm && getPackageJsonInfo(nm.packageDirectory, nm.subModuleName, /*onlyRecordFailures*/ false, state);
- var packageId = packageInfo && packageInfo.packageId;
- return withPackageId(packageId, resolvedFromFile);
+ var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
+ var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined;
+ return withPackageId(packageInfo, resolvedFromFile);
}
}
if (!onlyRecordFailures) {
@@ -27055,11 +27151,10 @@ var ts;
* (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.)
*
* packageDirectory is the directory of the package itself.
- * subModuleName is the path within the package.
- * For `blah/node_modules/foo/index.d.ts` this is { packageDirectory: "foo", subModuleName: "index.d.ts" }. (Part before "/node_modules/" is ignored.)
- * For `/node_modules/foo/bar.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
- * For `/node_modules/@types/foo/bar/index.d.ts` this is { packageDirectory: "@types/foo", subModuleName: "bar/index.d.ts" }.
- * For `/node_modules/foo/bar/index.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
+ * For `blah/node_modules/foo/index.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/foo/bar.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo"
+ * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo"
*/
function parseNodeModuleFromPath(resolved) {
var path = ts.normalizePath(resolved.path);
@@ -27072,26 +27167,12 @@ var ts;
if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) {
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
}
- var packageDirectory = path.slice(0, indexAfterPackageName);
- var subModuleName = ts.removeExtension(path.slice(indexAfterPackageName + 1), resolved.ext) + ".d.ts" /* Dts */;
- return { packageDirectory: packageDirectory, subModuleName: subModuleName };
+ return path.slice(0, indexAfterPackageName);
}
function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
}
- function addExtensionAndIndex(path) {
- if (path === "") {
- return "index.d.ts";
- }
- if (ts.endsWith(path, ".d.ts")) {
- return path;
- }
- if (path === "index" || ts.endsWith(path, "/index")) {
- return path + ".d.ts";
- }
- return path + "/index.d.ts";
- }
function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
}
@@ -27165,52 +27246,22 @@ var ts;
}
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
if (considerPackageJson === void 0) { considerPackageJson = true; }
- var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, "", onlyRecordFailures, state) : undefined;
- var packageId = packageInfo && packageInfo.packageId;
+ var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
var versionPaths = packageInfo && packageInfo.versionPaths;
- return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
+ return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
}
- function getPackageJsonInfo(packageDirectory, subModuleName, onlyRecordFailures, state) {
+ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
var host = state.host, traceEnabled = state.traceEnabled;
var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
if (directoryExists && host.fileExists(packageJsonPath)) {
var packageJsonContent = ts.readJson(packageJsonPath, host);
- if (subModuleName === "") { // looking up the root - need to handle types/typings/main redirects for subModuleName
- var path = readPackageJsonTypesFields(packageJsonContent, packageDirectory, state);
- if (typeof path === "string") {
- subModuleName = addExtensionAndIndex(path.substring(packageDirectory.length + 1));
- }
- else {
- var jsPath = readPackageJsonMainField(packageJsonContent, packageDirectory, state);
- if (typeof jsPath === "string" && jsPath.length > packageDirectory.length) {
- var potentialSubModule_1 = jsPath.substring(packageDirectory.length + 1);
- subModuleName = (ts.forEach(ts.supportedJSExtensions, function (extension) {
- return ts.tryRemoveExtension(potentialSubModule_1, extension);
- }) || potentialSubModule_1) + ".d.ts" /* Dts */;
- }
- else {
- subModuleName = "index.d.ts";
- }
- }
- }
- if (!ts.endsWith(subModuleName, ".d.ts" /* Dts */)) {
- subModuleName = addExtensionAndIndex(subModuleName);
- }
- var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
- var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string"
- ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version }
- : undefined;
if (traceEnabled) {
- if (packageId) {
- trace(host, ts.Diagnostics.Found_package_json_at_0_Package_ID_is_1, packageJsonPath, ts.packageIdToString(packageId));
- }
- else {
- trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
- }
+ trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
}
- return { packageJsonContent: packageJsonContent, packageId: packageId, versionPaths: versionPaths };
+ var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
+ return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
}
else {
if (directoryExists && traceEnabled) {
@@ -27349,37 +27400,31 @@ var ts;
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
- var packageJsonContent;
- var packageId;
- var versionPaths;
- var packageInfo = getPackageJsonInfo(candidate, "", !nodeModulesDirectoryExists, state);
+ var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
if (packageInfo) {
- (packageJsonContent = packageInfo.packageJsonContent, packageId = packageInfo.packageId, versionPaths = packageInfo.versionPaths);
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
if (fromFile) {
return noPackageId(fromFile);
}
- var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, fromDirectory);
+ var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
+ return withPackageId(packageInfo, fromDirectory);
}
var loader = function (extensions, candidate, onlyRecordFailures, state) {
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
- loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, pathAndExtension);
+ loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
+ return withPackageId(packageInfo, pathAndExtension);
};
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
if (rest !== "") { // If "rest" is empty, we just did this search above.
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
// Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings.
- var packageInfo_1 = getPackageJsonInfo(packageDirectory, rest, !nodeModulesDirectoryExists, state);
- if (packageInfo_1)
- (packageId = packageInfo_1.packageId, versionPaths = packageInfo_1.versionPaths);
- if (versionPaths) {
+ packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
+ if (packageInfo && packageInfo.versionPaths) {
if (state.traceEnabled) {
- trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, rest);
+ trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest);
}
var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, versionPaths.paths, loader, !packageDirectoryExists, state);
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
if (fromPaths) {
return fromPaths.value;
}
@@ -29834,7 +29879,7 @@ var ts;
}
break;
default:
- ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer));
+ ts.Debug.failBadSyntaxKind(thisContainer);
}
}
function bindSpecialPropertyDeclaration(node) {
@@ -29892,7 +29937,7 @@ var ts;
// Fix up parent pointers since we're going to use these nodes before we bind into them
node.left.parent = node;
node.right.parent = node;
- if (ts.isIdentifier(lhs.expression) && container === file && isNameOfExportsOrModuleExportsAliasDeclaration(file, lhs.expression)) {
+ if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) {
// This can be an alias for the 'exports' or 'module.exports' names, e.g.
// var util = module.exports;
// util.property = function ...
@@ -30247,20 +30292,29 @@ var ts;
}
}
function isExportsOrModuleExportsOrAlias(sourceFile, node) {
- return ts.isExportsIdentifier(node) ||
- ts.isModuleExportsPropertyAccessExpression(node) ||
- ts.isIdentifier(node) && isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node);
+ var i = 0;
+ var q = [node];
+ while (q.length && i < 100) {
+ i++;
+ node = q.shift();
+ if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) {
+ return true;
+ }
+ else if (ts.isIdentifier(node)) {
+ var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
+ if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
+ var init = symbol.valueDeclaration.initializer;
+ q.push(init);
+ if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) {
+ q.push(init.left);
+ q.push(init.right);
+ }
+ }
+ }
+ }
+ return false;
}
ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
- function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) {
- var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
- return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) &&
- !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer);
- }
- function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) {
- return isExportsOrModuleExportsOrAlias(sourceFile, node) ||
- (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && (isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.left) || isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.right)));
- }
function lookupSymbolForNameWorker(container, name) {
var local = container.locals && container.locals.get(name);
if (local) {
@@ -31400,6 +31454,10 @@ var ts;
node = ts.getParseTreeNode(node);
return node ? getTypeOfNode(node) : errorType;
},
+ getTypeOfAssignmentPattern: function (nodeIn) {
+ var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
+ return node && getTypeOfAssignmentPattern(node) || errorType;
+ },
getPropertySymbolOfDestructuringAssignment: function (locationIn) {
var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
@@ -34500,7 +34558,7 @@ var ts;
context.approximateLength += 6;
return ts.createKeywordTypeNode(137 /* ObjectKeyword */);
}
- if (type.flags & 262144 /* TypeParameter */ && type.isThisType) {
+ if (isThisTypeParameter(type)) {
if (context.flags & 4194304 /* InObjectTypeLiteral */) {
if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
context.encounteredError = true;
@@ -35190,6 +35248,11 @@ var ts;
function lookupTypeParameterNodes(chain, index, context) {
ts.Debug.assert(chain && 0 <= index && index < chain.length);
var symbol = chain[index];
+ var symbolId = "" + getSymbolId(symbol);
+ if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
+ return undefined;
+ }
+ (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
var typeParameterNodes;
if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) {
var parentSymbol = symbol;
@@ -36130,7 +36193,7 @@ var ts;
return type;
}
else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(declaredType, declaration, type);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
}
}
return declaredType;
@@ -36449,7 +36512,7 @@ var ts;
type = getTypeOfEnumMember(symbol);
}
else {
- return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol));
+ return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
}
if (!popTypeResolution()) {
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
@@ -37719,10 +37782,10 @@ var ts;
// Union the result types when more than one signature matches
if (unionSignatures.length > 1) {
var thisParameter = signature.thisParameter;
- if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) {
- // TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do
+ var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
+ if (firstThisParameterOfUnionSignatures) {
var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */);
- thisParameter = createSymbolWithType(signature.thisParameter, thisType);
+ thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
}
s = createUnionSignature(signature, unionSignatures);
s.thisParameter = thisParameter;
@@ -38288,15 +38351,19 @@ var ts;
function getConstraintOfIndexedAccess(type) {
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
}
+ function getSimplifiedTypeOrConstraint(type) {
+ var simplified = getSimplifiedType(type, /*writing*/ false);
+ return simplified !== type ? simplified : getConstraintOfType(type);
+ }
function getConstraintFromIndexedAccess(type) {
- var indexConstraint = getConstraintOfType(type.indexType);
+ var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
if (indexConstraint && indexConstraint !== type.indexType) {
var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
if (indexedAccess) {
return indexedAccess;
}
}
- var objectConstraint = getConstraintOfType(type.objectType);
+ var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
if (objectConstraint && objectConstraint !== type.objectType) {
return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
}
@@ -40285,6 +40352,14 @@ var ts;
types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
return true;
}
+ function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
+ var result = createType(2097152 /* Intersection */);
+ result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
+ result.types = types;
+ result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
+ result.aliasTypeArguments = aliasTypeArguments;
+ return result;
+ }
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
@@ -40322,30 +40397,36 @@ var ts;
if (typeSet.length === 1) {
return typeSet[0];
}
- if (includes & 1048576 /* Union */) {
- if (intersectUnionsOfPrimitiveTypes(typeSet)) {
- // When the intersection creates a reduced set (which might mean that *all* union types have
- // disappeared), we restart the operation to get a new set of combined flags. Once we have
- // reduced we'll never reduce again, so this occurs at most once.
- return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
- }
- // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
- // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
- var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
- var unionType = typeSet[unionIndex_1];
- return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
- }
var id = getTypeListId(typeSet);
- var type = intersectionTypes.get(id);
- if (!type) {
- type = createType(2097152 /* Intersection */);
- intersectionTypes.set(id, type);
- type.objectFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */);
- type.types = typeSet;
- type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
- type.aliasTypeArguments = aliasTypeArguments;
+ var result = intersectionTypes.get(id);
+ if (!result) {
+ if (includes & 1048576 /* Union */) {
+ if (intersectUnionsOfPrimitiveTypes(typeSet)) {
+ // When the intersection creates a reduced set (which might mean that *all* union types have
+ // disappeared), we restart the operation to get a new set of combined flags. Once we have
+ // reduced we'll never reduce again, so this occurs at most once.
+ result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ else {
+ // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
+ // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
+ // If the estimated size of the resulting union type exceeds 100000 constituents, report an error.
+ var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 /* Union */ ? t.types.length : 1); }, 1);
+ if (size >= 100000) {
+ error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
+ return errorType;
+ }
+ var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
+ var unionType = typeSet[unionIndex_1];
+ result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
+ }
+ }
+ else {
+ result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ intersectionTypes.set(id, result);
}
- return type;
+ return result;
}
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
@@ -40478,7 +40559,7 @@ var ts;
}
return false;
}
- function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, accessNode, accessFlags) {
+ function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined;
var propName = isTypeUsableAsPropertyName(indexType) ?
getPropertyNameFromType(indexType) :
@@ -40516,6 +40597,7 @@ var ts;
error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
}
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */));
return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
}
}
@@ -40537,13 +40619,7 @@ var ts;
error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
return indexInfo.type;
}
- if (indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
- if (accessExpression) {
- error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
- return indexInfo.type;
- }
- return undefined;
- }
+ errorIfWritingToReadonlyIndex(indexInfo);
return indexInfo.type;
}
if (indexType.flags & 131072 /* Never */) {
@@ -40556,7 +40632,7 @@ var ts;
if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) {
error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
- else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
+ else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
}
@@ -40576,7 +40652,25 @@ var ts;
error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion_1);
}
else {
- error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType));
+ var errorInfo = void 0;
+ if (indexType.flags & 1024 /* EnumLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 8192 /* UniqueESSymbol */) {
+ var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 128 /* StringLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & 256 /* NumberLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
+ }
+ errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType));
+ diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
}
}
}
@@ -40603,6 +40697,11 @@ var ts;
return indexType;
}
return undefined;
+ function errorIfWritingToReadonlyIndex(indexInfo) {
+ if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
+ error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
+ }
+ }
}
function getIndexNodeForAccessExpression(accessNode) {
return accessNode.kind === 191 /* ElementAccessExpression */
@@ -40619,6 +40718,9 @@ var ts;
function isGenericIndexType(type) {
return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */);
}
+ function isThisTypeParameter(type) {
+ return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
+ }
function getSimplifiedType(type, writing) {
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
@@ -40754,7 +40856,7 @@ var ts;
var wasMissingProp = false;
for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
var t = _a[_i];
- var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, accessNode, accessFlags);
+ var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
if (propType) {
propTypes.push(propType);
}
@@ -40772,7 +40874,7 @@ var ts;
}
return accessFlags & 2 /* Writing */ ? getIntersectionType(propTypes) : getUnionType(propTypes);
}
- return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, accessNode, accessFlags | 4 /* CacheSymbol */);
+ return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */);
}
function getTypeFromIndexedAccessTypeNode(node) {
var links = getNodeLinks(node);
@@ -43318,8 +43420,7 @@ var ts;
}
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
// simplified form of T or, if T doesn't simplify, the constraint of T.
- var simplified = getSimplifiedType(target.type, /*writing*/ false);
- var constraint = simplified !== target.type ? simplified : getConstraintOfType(target.type);
+ var constraint = getSimplifiedTypeOrConstraint(target.type);
if (constraint) {
// We require Ternary.True here such that circular constraints don't cause
// false positives. For example, given 'T extends { [K in keyof T]: string }',
@@ -46860,7 +46961,7 @@ var ts;
return !assumeTrue;
}
function narrowByInKeyword(type, literal, assumeTrue) {
- if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) {
+ if (type.flags & (1048576 /* Union */ | 524288 /* Object */) || isThisTypeParameter(type)) {
var propName_1 = ts.escapeLeadingUnderscores(literal.text);
return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
}
@@ -48412,8 +48513,8 @@ var ts;
// For a (non-symbol) computed property, there is no reason to look up the name
// in the type. It will just be "__computed", which does not appear in any
// SymbolTable.
- var symbolName_2 = getSymbolOfNode(element).escapedName;
- var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_2);
+ var symbolName_3 = getSymbolOfNode(element).escapedName;
+ var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
if (propertyType) {
return propertyType;
}
@@ -49888,7 +49989,7 @@ var ts;
return anyType;
}
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
- reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType);
+ reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
}
return errorType;
}
@@ -50253,7 +50354,7 @@ var ts;
}
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
var accessFlags = ts.isAssignmentTarget(node) ?
- 2 /* Writing */ | (isGenericObjectType(objectType) ? 1 /* NoIndexSignatures */ : 0) :
+ 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) :
0 /* None */;
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
return checkIndexedAccessIndexType(indexedAccessType, node);
@@ -52833,15 +52934,16 @@ var ts;
if (strictNullChecks && properties.length === 0) {
return checkNonNullType(sourceType, node);
}
- for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
- var p = properties_4[_i];
- checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis);
+ for (var i = 0; i < properties.length; i++) {
+ checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
}
return sourceType;
}
/** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */
- function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) {
+ function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
if (rightIsThis === void 0) { rightIsThis = false; }
+ var properties = node.properties;
+ var property = properties[propertyIndex];
if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) {
var name = property.name;
var exprType = getLiteralTypeFromPropertyName(name);
@@ -52858,18 +52960,26 @@ var ts;
return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
}
else if (property.kind === 278 /* SpreadAssignment */) {
- if (languageVersion < 8 /* ESNext */) {
- checkExternalEmitHelpers(property, 4 /* Rest */);
+ if (propertyIndex < properties.length - 1) {
+ error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
}
- var nonRestNames = [];
- if (allProperties) {
- for (var i = 0; i < allProperties.length - 1; i++) {
- nonRestNames.push(allProperties[i].name);
+ else {
+ if (languageVersion < 8 /* ESNext */) {
+ checkExternalEmitHelpers(property, 4 /* Rest */);
+ }
+ var nonRestNames = [];
+ if (allProperties) {
+ for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
+ var otherProperty = allProperties_1[_i];
+ if (!ts.isSpreadAssignment(otherProperty)) {
+ nonRestNames.push(otherProperty.name);
+ }
+ }
}
+ var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
+ checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
+ return checkDestructuringAssignment(property.expression, type);
}
- var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
- checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
- return checkDestructuringAssignment(property.expression, type);
}
else {
error(property, ts.Diagnostics.Property_assignment_expected);
@@ -54808,7 +54918,7 @@ var ts;
case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591
return 1 /* ExportValue */;
default:
- return ts.Debug.fail(ts.Debug.showSyntaxKind(d));
+ return ts.Debug.failBadSyntaxKind(d);
}
}
}
@@ -55973,7 +56083,7 @@ var ts;
if (type !== errorType && declarationType !== errorType &&
!isTypeIdenticalTo(type, declarationType) &&
!(symbol.flags & 67108864 /* Assignment */)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
}
if (node.initializer) {
checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined);
@@ -55992,12 +56102,16 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) {
+ function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */
? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
: ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
- error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType));
+ var declName = ts.declarationNameToString(nextDeclarationName);
+ var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
+ if (firstDeclaration) {
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
+ }
}
function areDeclarationFlagsIdentical(left, right) {
if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) ||
@@ -57138,8 +57252,8 @@ var ts;
for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
var base = baseTypes_2[_i];
var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
- for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) {
- var prop = properties_5[_a];
+ for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) {
+ var prop = properties_4[_a];
var existing = seen.get(prop.escapedName);
if (!existing) {
seen.set(prop.escapedName, { prop: prop, containingType: base });
@@ -58755,7 +58869,7 @@ var ts;
// }
// [ a ] from
// [a] = [ some array ...]
- function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) {
+ function getTypeOfAssignmentPattern(expr) {
ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */);
// If this is from "for of"
// for ( { a } of elems) {
@@ -58773,15 +58887,17 @@ var ts;
// If this is from nested object binding pattern
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
if (expr.parent.kind === 276 /* PropertyAssignment */) {
- var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent);
- return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217
+ var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
+ var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType;
+ var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent);
+ return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex);
}
// Array literal assignment - array destructuring pattern
- ts.Debug.assert(expr.parent.kind === 188 /* ArrayLiteralExpression */);
+ var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
// [{ property1: p1, property2 }] = elems;
- var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent);
- var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
- return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); // TODO: GH#18217
+ var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
+ var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
+ return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
}
// Gets the property symbol corresponding to the property in destructuring assignment
// 'property1' from
@@ -58791,7 +58907,7 @@ var ts;
// [a] = [ property1, property2 ]
function getPropertySymbolOfDestructuringAssignment(location) {
// Get the type of the object or array literal and then look for property of given name in the type
- var typeOfObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(location.parent.parent);
+ var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
}
function getRegularTypeOfExpression(expr) {
@@ -58957,12 +59073,16 @@ var ts;
}
return undefined;
}
+ function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
+ return ts.isBindingElement(symbol.valueDeclaration)
+ && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */;
+ }
function isSymbolOfDeclarationWithCollidingName(symbol) {
if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) {
var links = getSymbolLinks(symbol);
if (links.isDeclarationWithCollidingName === undefined) {
var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
- if (ts.isStatementWithLocals(container)) {
+ if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) {
// redeclaration - always should be renamed
@@ -64445,7 +64565,7 @@ var ts;
function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
if (property === firstAccessor) {
- var properties_6 = [];
+ var properties_5 = [];
if (getAccessor) {
var getterFunction = ts.createFunctionExpression(getAccessor.modifiers,
/*asteriskToken*/ undefined,
@@ -64456,7 +64576,7 @@ var ts;
ts.setTextRange(getterFunction, getAccessor);
ts.setOriginalNode(getterFunction, getAccessor);
var getter = ts.createPropertyAssignment("get", getterFunction);
- properties_6.push(getter);
+ properties_5.push(getter);
}
if (setAccessor) {
var setterFunction = ts.createFunctionExpression(setAccessor.modifiers,
@@ -64468,15 +64588,15 @@ var ts;
ts.setTextRange(setterFunction, setAccessor);
ts.setOriginalNode(setterFunction, setAccessor);
var setter = ts.createPropertyAssignment("set", setterFunction);
- properties_6.push(setter);
+ properties_5.push(setter);
}
- properties_6.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
- properties_6.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"),
/*typeArguments*/ undefined, [
receiver,
createExpressionForPropertyName(property.name),
- ts.createObjectLiteral(properties_6, multiLine)
+ ts.createObjectLiteral(properties_5, multiLine)
]),
/*location*/ firstAccessor);
return ts.aggregateTransformFlags(expression);
@@ -66455,7 +66575,7 @@ var ts;
* @param nodes The NodeArray.
*/
function liftToBlock(nodes) {
- Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
+ ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
}
ts.liftToBlock = liftToBlock;
@@ -66520,73 +66640,6 @@ var ts;
function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
}
- var Debug;
- (function (Debug) {
- var isDebugInfoEnabled = false;
- function failBadSyntaxKind(node, message) {
- return Debug.fail((message || "Unexpected node.") + "\r\nNode " + ts.formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
- }
- Debug.failBadSyntaxKind = failBadSyntaxKind;
- Debug.assertEachNode = Debug.shouldAssert(1 /* Normal */)
- ? function (nodes, test, message) { return Debug.assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertEachNode); }
- : ts.noop;
- Debug.assertNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertNode); }
- : ts.noop;
- Debug.assertOptionalNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
- : ts.noop;
- Debug.assertOptionalToken = Debug.shouldAssert(1 /* Normal */)
- ? function (node, kind, message) { return Debug.assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was not a '" + ts.formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
- : ts.noop;
- Debug.assertMissingNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, message) { return Debug.assert(node === undefined, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
- : ts.noop;
- /**
- * Injects debug information into frequently used types.
- */
- function enableDebugInfo() {
- if (isDebugInfoEnabled)
- return;
- // Add additional properties in debug mode to assist with debugging.
- Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatSymbolFlags(this.flags); } }
- });
- Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } },
- __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } },
- __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
- });
- var nodeConstructors = [
- ts.objectAllocator.getNodeConstructor(),
- ts.objectAllocator.getIdentifierConstructor(),
- ts.objectAllocator.getTokenConstructor(),
- ts.objectAllocator.getSourceFileConstructor()
- ];
- for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
- var ctor = nodeConstructors_1[_i];
- if (!ctor.prototype.hasOwnProperty("__debugKind")) {
- Object.defineProperties(ctor.prototype, {
- __debugKind: { get: function () { return ts.formatSyntaxKind(this.kind); } },
- __debugModifierFlags: { get: function () { return ts.formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
- __debugTransformFlags: { get: function () { return ts.formatTransformFlags(this.transformFlags); } },
- __debugEmitFlags: { get: function () { return ts.formatEmitFlags(ts.getEmitFlags(this)); } },
- __debugGetText: {
- value: function (includeTrivia) {
- if (ts.nodeIsSynthesized(this))
- return "";
- var parseNode = ts.getParseTreeNode(this);
- var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
- return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
- }
- }
- });
- }
- }
- isDebugInfoEnabled = true;
- }
- Debug.enableDebugInfo = enableDebugInfo;
- })(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
/* @internal */
var ts;
@@ -68962,8 +69015,8 @@ var ts;
* @param receiver The receiver on which each property should be assigned.
*/
function addInitializedPropertyStatements(statements, properties, receiver) {
- for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
- var property = properties_7[_i];
+ for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) {
+ var property = properties_6[_i];
var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver));
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
ts.setCommentRange(statement, property);
@@ -68979,8 +69032,8 @@ var ts;
*/
function generateInitializedPropertyExpressions(properties, receiver) {
var expressions = [];
- for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
- var property = properties_8[_i];
+ for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
+ var property = properties_7[_i];
var expression = transformInitializedProperty(property, receiver);
ts.startOnNewLine(expression);
ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
@@ -71522,6 +71575,8 @@ var ts;
return visitObjectLiteralExpression(node);
case 205 /* BinaryExpression */:
return visitBinaryExpression(node, noDestructuringValue);
+ case 275 /* CatchClause */:
+ return visitCatchClause(node);
case 238 /* VariableDeclaration */:
return visitVariableDeclaration(node);
case 228 /* ForOfStatement */:
@@ -71658,6 +71713,23 @@ var ts;
}
return ts.visitEachChild(node, visitor, context);
}
+ function visitCatchClause(node) {
+ if (node.variableDeclaration &&
+ ts.isBindingPattern(node.variableDeclaration.name) &&
+ node.variableDeclaration.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) {
+ var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
+ var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*type*/ undefined, name);
+ var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
+ var block = ts.visitNode(node.block, visitor, ts.isBlock);
+ if (ts.some(visitedBindings)) {
+ block = ts.updateBlock(block, [
+ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings)
+ ].concat(block.statements));
+ }
+ return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block);
+ }
+ return ts.visitEachChild(node, visitor, context);
+ }
/**
* Visits a VariableDeclaration node with a binding pattern.
*
@@ -72801,62 +72873,63 @@ var ts;
HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block";
HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement";
HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock";
- HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement";
- HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper";
+ HierarchyFacts[HierarchyFacts["IterationContainer"] = 1024] = "IterationContainer";
+ HierarchyFacts[HierarchyFacts["ForStatement"] = 2048] = "ForStatement";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 4096] = "ForInOrForOfStatement";
+ HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 8192] = "ConstructorWithCapturedSuper";
// NOTE: do not add more ancestor flags without also updating AncestorFactsMask below.
// NOTE: when adding a new ancestor flag, be sure to update the subtree flags below.
//
// Ancestor masks
//
- HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 8191] = "AncestorFactsMask";
+ HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask";
// We are always in *some* kind of block scope, but only specific block-scope containers are
// top-level or Blocks.
HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes";
- HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes";
+ HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 7104] = "BlockScopeExcludes";
// A source file is a top-level block scope.
HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes";
- HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes";
+ HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 8064] = "SourceFileExcludes";
// Functions, methods, and accessors are both new lexical scopes and new block scopes.
HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes";
- HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 8094] = "FunctionExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes";
HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes";
- HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 8086] = "AsyncFunctionBodyExcludes";
+ HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes";
// Arrow functions are lexically scoped to their container, but are new block scopes.
HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes";
- HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 8064] = "ArrowFunctionExcludes";
+ HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 15232] = "ArrowFunctionExcludes";
// Constructors are both new lexical scopes and new block scopes. Constructors are also
// always considered non-static members of a class.
HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes";
- HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 8086] = "ConstructorExcludes";
+ HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes";
// 'do' and 'while' statements are not block scopes. We track that the subtree is contained
// within an IterationStatement to indicate whether the embedded statement is an
// IterationStatementBlock.
- HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes";
+ HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 1280] = "DoOrWhileStatementIncludes";
HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes";
// 'for' statements are new block scopes and have special handling for 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 3328] = "ForStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 5056] = "ForStatementExcludes";
// 'for-in' and 'for-of' statements are new block scopes and have special handling for
// 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 5376] = "ForInOrForOfStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 3008] = "ForInOrForOfStatementExcludes";
// Blocks (other than function bodies) are new block scopes.
HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes";
- HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes";
+ HierarchyFacts[HierarchyFacts["BlockExcludes"] = 6976] = "BlockExcludes";
HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes";
- HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes";
+ HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 7104] = "IterationStatementBlockExcludes";
//
// Subtree facts
//
- HierarchyFacts[HierarchyFacts["NewTarget"] = 8192] = "NewTarget";
- HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 16384] = "CapturedLexicalThis";
+ HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget";
+ HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 32768] = "CapturedLexicalThis";
//
// Subtree masks
//
- HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -8192] = "SubtreeFactsMask";
+ HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask";
HierarchyFacts[HierarchyFacts["ArrowFunctionSubtreeExcludes"] = 0] = "ArrowFunctionSubtreeExcludes";
- HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 24576] = "FunctionSubtreeExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 49152] = "FunctionSubtreeExcludes";
})(HierarchyFacts || (HierarchyFacts = {}));
function transformES2015(context) {
var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
@@ -72905,7 +72978,7 @@ var ts;
*/
function enterSubtree(excludeFacts, includeFacts) {
var ancestorFacts = hierarchyFacts;
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 8191 /* AncestorFactsMask */;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */;
return ancestorFacts;
}
/**
@@ -72916,17 +72989,17 @@ var ts;
* @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated.
*/
function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -8192 /* SubtreeFactsMask */ | ancestorFacts;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts;
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
- return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0
+ return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0
&& node.kind === 231 /* ReturnStatement */
&& !node.expression;
}
function shouldVisitNode(node) {
return (node.transformFlags & 128 /* ContainsES2015 */) !== 0
|| convertedLoopState !== undefined
- || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
+ || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
|| (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node))
|| (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0;
}
@@ -73043,7 +73116,7 @@ var ts;
}
}
function visitSourceFile(node) {
- var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
+ var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
var prologue = [];
var statements = [];
startLexicalEnvironment();
@@ -73070,7 +73143,7 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitCaseBlock(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -73097,7 +73170,7 @@ var ts;
}
function visitThisKeyword(node) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
if (convertedLoopState) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
@@ -73340,7 +73413,7 @@ var ts;
function addConstructor(statements, node, extendsClauseElement) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8086 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
+ var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
var constructor = ts.getFirstConstructorWithBody(node);
var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
var constructorFunction = ts.createFunctionDeclaration(
@@ -73354,7 +73427,7 @@ var ts;
ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */);
}
statements.push(constructorFunction);
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
}
/**
@@ -73447,7 +73520,7 @@ var ts;
}
}
if (superCallExpression) {
- hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */;
+ hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
}
// visit the remaining statements
@@ -73751,7 +73824,7 @@ var ts;
* @param node A node.
*/
function insertCaptureThisForNodeIfNeeded(statements, node) {
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
insertCaptureThisForNode(statements, node, ts.createThis());
return true;
}
@@ -73769,7 +73842,7 @@ var ts;
ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
}
function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
- if (hierarchyFacts & 8192 /* NewTarget */) {
+ if (hierarchyFacts & 16384 /* NewTarget */) {
var newTarget = void 0;
switch (node.kind) {
case 198 /* ArrowFunction */:
@@ -73939,11 +74012,11 @@ var ts;
*/
function visitArrowFunction(node) {
if (node.transformFlags & 2048 /* ContainsLexicalThis */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8064 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
+ var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
var func = ts.createFunctionExpression(
/*modifiers*/ undefined,
/*asteriskToken*/ undefined,
@@ -73953,7 +74026,7 @@ var ts;
ts.setTextRange(func, node);
ts.setOriginalNode(func, node);
ts.setEmitFlags(func, 8 /* CapturesThis */);
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */) {
enableSubstitutionsForCapturedThis();
}
// If an arrow function contains
@@ -73968,16 +74041,16 @@ var ts;
*/
function visitFunctionExpression(node) {
var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */
- ? enterSubtree(8086 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionExpression(node,
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -73992,13 +74065,13 @@ var ts;
function visitFunctionDeclaration(node) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionDeclaration(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name,
@@ -74016,14 +74089,14 @@ var ts;
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */)
- ? enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- if (hierarchyFacts & 8192 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
+ if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
name = ts.getGeneratedNameForNode(node);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -74118,8 +74191,8 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */
- ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
- : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */);
+ ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
+ : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -74302,11 +74375,11 @@ var ts;
&& isDeclaredInLoop
&& (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0);
var emitExplicitInitializer = !emittedAsTopLevel
- && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0
+ && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0
&& (!resolver.isDeclarationWithCollidingName(node)
|| (isDeclaredInLoop
&& !isCapturedInFunction
- && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0));
+ && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0));
return emitExplicitInitializer;
}
/**
@@ -74377,21 +74450,21 @@ var ts;
}
function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
- var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert);
+ var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
}
function visitDoOrWhileStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
}
function visitForStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement);
}
function visitForInStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
}
function visitForOfStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
}
function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
var statements = [];
@@ -74499,7 +74572,7 @@ var ts;
ts.setTextRange(forStatement, node);
return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
}
- function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) {
+ function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined);
var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined);
@@ -74510,9 +74583,13 @@ var ts;
var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []);
hoistVariableDeclaration(errorRecord);
hoistVariableDeclaration(returnMethod);
+ // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration
+ var initializer = ancestorFacts & 1024 /* IterationContainer */
+ ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
+ : values;
var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(
/*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
- ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression),
+ ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, initializer), node.expression),
ts.createVariableDeclaration(result, /*type*/ undefined, next)
]), node.expression), 2097152 /* NoHoisting */),
/*condition*/ ts.createLogicalNot(ts.createPropertyAccess(result, "done")),
@@ -74623,7 +74700,7 @@ var ts;
}
}
}
- function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) {
+ function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
if (!shouldConvertIterationStatement(node)) {
var saveAllowedNonLabeledJumps = void 0;
if (convertedLoopState) {
@@ -74633,7 +74710,7 @@ var ts;
convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */;
}
var result = convert
- ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined)
+ ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts)
: ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
if (convertedLoopState) {
convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
@@ -74658,7 +74735,7 @@ var ts;
var loop;
if (bodyFunction) {
if (convert) {
- loop = convert(node, outermostLabeledStatement, bodyFunction.part);
+ loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
}
else {
var clone_3 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, /*multiLine*/ true));
@@ -75176,7 +75253,7 @@ var ts;
return expression;
}
function visitCatchClause(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated;
ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
if (ts.isBindingPattern(node.variableDeclaration.name)) {
@@ -75224,7 +75301,7 @@ var ts;
ts.Debug.assert(!ts.isComputedPropertyName(node.name));
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var updated;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
@@ -75234,7 +75311,7 @@ var ts;
else {
updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return updated;
}
@@ -75720,7 +75797,7 @@ var ts;
}
function visitMetaProperty(node) {
if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") {
- hierarchyFacts |= 8192 /* NewTarget */;
+ hierarchyFacts |= 16384 /* NewTarget */;
return ts.createFileLevelUniqueName("_newTarget");
}
return node;
@@ -75735,7 +75812,7 @@ var ts;
function onEmitNode(hint, node, emitCallback) {
if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) {
// If we are tracking a captured `this`, keep track of the enclosing function.
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
? 65 /* FunctionIncludes */ | 16 /* CapturesThis */
: 65 /* FunctionIncludes */);
previousOnEmitNode(hint, node, emitCallback);
@@ -87669,6 +87746,8 @@ var ts;
case 159 /* GetAccessor */:
case 160 /* SetAccessor */:
return generateNameForMethodOrAccessor(node);
+ case 150 /* ComputedPropertyName */:
+ return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true);
default:
return makeTempVariableName(0 /* Auto */);
}
@@ -90360,7 +90439,10 @@ var ts;
if (isRedirect) {
inputName = getProjectReferenceRedirect(fileName) || fileName;
}
- if (ts.getNormalizedAbsolutePath(checkedName, currentDirectory) !== ts.getNormalizedAbsolutePath(inputName, currentDirectory)) {
+ // Check if it differs only in drive letters its ok to ignore that error:
+ var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
+ var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory);
+ if (checkedAbsolutePath !== inputAbsolutePath) {
reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd);
}
}
@@ -90896,10 +90978,10 @@ var ts;
if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
}
- var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
+ var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
@@ -93300,11 +93382,11 @@ var ts;
}
function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
var result = ts.createMap();
- var symlinks = ts.mapDefined(files, function (sf) {
- return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) {
+ var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
+ return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
- });
- });
+ })));
+ }));
for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];
@@ -99034,7 +99116,7 @@ var ts;
var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of.
var entries = pathCompletions.map(function (_a) {
var name = _a.name, kind = _a.kind, span = _a.span, extension = _a.extension;
- return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: "0", replacementSpan: span });
+ return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: Completions.SortText.LocationPriority, replacementSpan: span });
});
return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
}
@@ -99637,6 +99719,14 @@ var ts;
(function (ts) {
var Completions;
(function (Completions) {
+ var SortText;
+ (function (SortText) {
+ SortText["LocationPriority"] = "0";
+ SortText["SuggestedClassMembers"] = "1";
+ SortText["GlobalsOrKeywords"] = "2";
+ SortText["AutoImportSuggestions"] = "3";
+ SortText["JavascriptIdentifiers"] = "4";
+ })(SortText = Completions.SortText || (Completions.SortText = {}));
var SymbolOriginInfoKind;
(function (SymbolOriginInfoKind) {
SymbolOriginInfoKind[SymbolOriginInfoKind["ThisType"] = 0] = "ThisType";
@@ -99671,8 +99761,9 @@ var ts;
var typeChecker = program.getTypeChecker();
var compilerOptions = program.getCompilerOptions();
var contextToken = ts.findPrecedingToken(position, sourceFile);
- if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position))
+ if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) {
return undefined;
+ }
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences);
if (stringCompletions) {
return stringCompletions;
@@ -99705,7 +99796,7 @@ var ts;
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries };
}
function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) {
- var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression;
+ var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap;
if (location && location.parent && ts.isJsxClosingElement(location.parent)) {
// In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag,
// instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element.
@@ -99719,20 +99810,20 @@ var ts;
name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"),
kind: "class" /* classElement */,
kindModifiers: undefined,
- sortText: "0",
+ sortText: SortText.LocationPriority,
};
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [entry] };
}
var entries = [];
if (isUncheckedFile(sourceFile, compilerOptions)) {
- var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap);
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217
}
else {
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
return undefined;
}
- getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap);
+ getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
}
if (keywordFilters !== 0 /* None */) {
var entryNames = ts.arrayToSet(entries, function (e) { return e.name; });
@@ -99774,7 +99865,7 @@ var ts;
name: realName,
kind: "warning" /* warning */,
kindModifiers: "",
- sortText: "1"
+ sortText: SortText.JavascriptIdentifiers
});
}
});
@@ -99783,14 +99874,9 @@ var ts;
return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal);
};
function createCompletionEntryForLiteral(literal) {
- return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: "0" };
+ return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
}
- function createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
- var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
- if (!info) {
- return undefined;
- }
- var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
+ function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
var insertText;
var replacementSpan;
if (origin && origin.kind === 0 /* ThisType */) {
@@ -99827,7 +99913,7 @@ var ts;
name: name,
kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol),
- sortText: "0",
+ sortText: sortText,
source: getSourceFromOrigin(origin),
hasAction: trueOrUndefined(!!origin && originIsExport(origin)),
isRecommended: trueOrUndefined(isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker)),
@@ -99845,7 +99931,7 @@ var ts;
function getSourceFromOrigin(origin) {
return origin && originIsExport(origin) ? ts.stripQuotes(origin.moduleSymbol.name) : undefined;
}
- function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap) {
+ function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) {
var start = ts.timestamp();
// Tracks unique names.
// We don't set this for global variables or completions from external module exports, because we can have multiple of those.
@@ -99855,14 +99941,18 @@ var ts;
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
var symbol = symbols_1[_i];
var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined;
- var entry = createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
- if (!entry) {
+ var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
+ if (!info) {
continue;
}
- var name = entry.name;
+ var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
if (uniques.has(name)) {
continue;
}
+ var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
+ if (!entry) {
+ continue;
+ }
// Latter case tests whether this is a global variable.
if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { // TODO: GH#18217
uniques.set(name, true);
@@ -99895,7 +99985,7 @@ var ts;
name: name,
kindModifiers: "" /* none */,
kind: "label" /* label */,
- sortText: "0"
+ sortText: SortText.LocationPriority
});
}
}
@@ -100272,6 +100362,7 @@ var ts;
var keywordFilters = 0 /* None */;
var symbols = [];
var symbolToOriginInfoMap = [];
+ var symbolToSortTextMap = [];
if (isRightOfDot) {
getTypeScriptMemberSymbols();
}
@@ -100317,7 +100408,8 @@ var ts;
recommendedCompletion: recommendedCompletion,
previousToken: previousToken,
isJsxInitializer: isJsxInitializer,
- insideJsDocTagTypeExpression: insideJsDocTagTypeExpression
+ insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
+ symbolToSortTextMap: symbolToSortTextMap
};
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
@@ -100499,14 +100591,22 @@ var ts;
var isTypeOnly = isTypeOnlyCompletion();
var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined");
+ for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
+ var symbol = symbols_2[_i];
+ if (!typeChecker.isArgumentsSymbol(symbol) &&
+ !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords;
+ }
+ }
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) {
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
if (thisType) {
- for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
- var symbol = _a[_i];
+ for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
+ var symbol = _b[_a];
symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ };
symbols.push(symbol);
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers;
}
}
}
@@ -100625,6 +100725,7 @@ var ts;
// So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`.
ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) {
symbols.push(resolvedModuleSymbol);
+ symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions;
symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false };
}
for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) {
@@ -100649,6 +100750,7 @@ var ts;
var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport };
if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) {
symbols.push(symbol);
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions;
symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin;
}
}
@@ -101285,7 +101387,7 @@ var ts;
name: ts.tokenToString(i),
kind: "keyword" /* keyword */,
kindModifiers: "" /* none */,
- sortText: "0"
+ sortText: SortText.GlobalsOrKeywords
});
}
return res;
@@ -102136,7 +102238,7 @@ var ts;
directImports.push(direct);
break;
default:
- ts.Debug.assertNever(direct, "Unexpected import kind: " + ts.Debug.showSyntaxKind(direct));
+ ts.Debug.failBadSyntaxKind(direct, "Unexpected import kind.");
}
}
}
@@ -102479,7 +102581,7 @@ var ts;
var sym = useLhsSymbol ? checker.getSymbolAtLocation(ts.cast(node.left, ts.isPropertyAccessExpression).name) : symbol;
// Better detection for GH#20803
if (sym && !(checker.getMergedSymbol(sym.parent).flags & 1536 /* Module */)) {
- ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.showSymbol(sym) + ", parent is " + ts.Debug.showSymbol(sym.parent));
+ ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.formatSymbol(sym) + ", parent is " + ts.Debug.formatSymbol(sym.parent));
}
return sym && exportInfo(sym, kind);
}
@@ -103179,7 +103281,7 @@ var ts;
if (symbol.flags & 33554432 /* Transient */)
return undefined;
// Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here.
- ts.Debug.fail("Unexpected symbol at " + ts.Debug.showSyntaxKind(node) + ": " + ts.Debug.showSymbol(symbol));
+ ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol));
}
return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent)
? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name)
@@ -103284,8 +103386,8 @@ var ts;
var sourceId = ts.getNodeId(sourceFile);
var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = ts.createMap());
var anyNewSymbols = false;
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
- var sym = symbols_2[_i];
+ for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) {
+ var sym = symbols_3[_i];
anyNewSymbols = ts.addToSeen(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
}
return anyNewSymbols;
@@ -107744,8 +107846,21 @@ var ts;
});
}
function containsPrecedingToken(startingToken, sourceFile, container) {
- var precedingToken = ts.Debug.assertDefined(ts.findPrecedingToken(startingToken.getFullStart(), sourceFile, startingToken.parent, /*excludeJsdoc*/ true));
- return ts.rangeContainsRange(container, precedingToken);
+ var pos = startingToken.getFullStart();
+ // There’s a possibility that `startingToken.parent` contains only `startingToken` and
+ // missing nodes, none of which are valid to be returned by `findPrecedingToken`. In that
+ // case, the preceding token we want is actually higher up the tree—almost definitely the
+ // next parent, but theoretically the situation with missing nodes might be happening on
+ // multiple nested levels.
+ var currentParent = startingToken.parent;
+ while (currentParent) {
+ var precedingToken = ts.findPrecedingToken(pos, sourceFile, currentParent, /*excludeJsdoc*/ true);
+ if (precedingToken) {
+ return ts.rangeContainsRange(container, precedingToken);
+ }
+ currentParent = currentParent.parent;
+ }
+ return ts.Debug.fail("Could not find preceding token");
}
function getArgumentInfoForCompletions(node, position, sourceFile) {
var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile);
@@ -108035,7 +108150,7 @@ var ts;
var _loop_7 = function (n) {
// If the node is not a subspan of its parent, this is a big problem.
// There have been crashes that might be caused by this violation.
- ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); });
+ ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); });
var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker);
if (argumentInfo) {
return { value: argumentInfo };
@@ -113101,11 +113216,11 @@ var ts;
function makeChange(changeTracker, sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
if (!ts.isIdentifier(token)) {
- return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.formatSyntaxKind(token.kind));
+ return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.Debug.formatSyntaxKind(token.kind));
}
var param = token.parent;
if (!ts.isParameter(param)) {
- return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.formatSyntaxKind(token.kind));
+ return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.Debug.formatSyntaxKind(token.kind));
}
var i = param.parent.parameters.indexOf(param);
ts.Debug.assert(!param.type, "Tried to add a parameter name to a parameter that already had one.");
@@ -121241,7 +121356,7 @@ var ts;
var textPos = ts.scanner.getTextPos();
if (textPos <= end) {
if (token === 73 /* Identifier */) {
- ts.Debug.fail("Did not expect " + ts.Debug.showSyntaxKind(parent) + " to have an Identifier in its trivia");
+ ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia");
}
nodes.push(createNode(token, pos, textPos, parent));
}
diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts
index 747fac8526ac3..9ef9e22011ce0 100644
--- a/lib/typescriptServices.d.ts
+++ b/lib/typescriptServices.d.ts
@@ -1969,6 +1969,7 @@ declare namespace ts {
*/
getExportSymbolOfSymbol(symbol: Symbol): Symbol;
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
+ getTypeOfAssignmentPattern(pattern: AssignmentPattern): Type;
getTypeAtLocation(node: Node): Type;
getTypeFromTypeNode(node: TypeNode): Type;
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js
index db5763584538e..10dfdc8afff20 100644
--- a/lib/typescriptServices.js
+++ b/lib/typescriptServices.js
@@ -75,7 +75,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.5";
/** The version of the TypeScript compiler release */
- ts.version = ts.versionMajorMinor + ".0-rc";
+ ts.version = ts.versionMajorMinor + ".1";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@@ -315,7 +315,7 @@ var ts;
ts.firstDefinedIterator = firstDefinedIterator;
function zipWith(arrayA, arrayB, callback) {
var result = [];
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
for (var i = 0; i < arrayA.length; i++) {
result.push(callback(arrayA[i], arrayB[i], i));
}
@@ -323,7 +323,7 @@ var ts;
}
ts.zipWith = zipWith;
function zipToIterator(arrayA, arrayB) {
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
var i = 0;
return {
next: function () {
@@ -337,7 +337,7 @@ var ts;
}
ts.zipToIterator = zipToIterator;
function zipToMap(keys, values) {
- Debug.assert(keys.length === values.length);
+ ts.Debug.assert(keys.length === values.length);
var map = createMap();
for (var i = 0; i < keys.length; ++i) {
map.set(keys[i], values[i]);
@@ -411,7 +411,7 @@ var ts;
return result;
}
}
- return Debug.fail();
+ return ts.Debug.fail();
}
ts.findMap = findMap;
function contains(array, value, equalityComparer) {
@@ -841,7 +841,7 @@ var ts;
continue;
case -1 /* LessThan */:
// If `array` is sorted, `next` should **never** be less than `last`.
- return Debug.fail("Array is unsorted.");
+ return ts.Debug.fail("Array is unsorted.");
}
deduplicated.push(last = next);
}
@@ -908,13 +908,13 @@ var ts;
loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
if (offsetB > 0) {
// Ensure `arrayB` is properly sorted.
- Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
}
loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
if (offsetA > startA) {
// Ensure `arrayA` is properly sorted. We only need to perform this check if
// `offsetA` has changed since we entered the loop.
- Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
}
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
case -1 /* LessThan */:
@@ -1084,7 +1084,7 @@ var ts;
}
ts.firstOrUndefined = firstOrUndefined;
function first(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[0];
}
ts.first = first;
@@ -1096,7 +1096,7 @@ var ts;
}
ts.lastOrUndefined = lastOrUndefined;
function last(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[array.length - 1];
}
ts.last = last;
@@ -1421,7 +1421,7 @@ var ts;
function cast(value, test) {
if (value !== undefined && test(value))
return value;
- return Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + Debug.getFunctionName(test) + "'.");
+ return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
}
ts.cast = cast;
/** Does nothing. */
@@ -1490,92 +1490,6 @@ var ts;
AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive";
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
})(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {}));
- var Debug;
- (function (Debug) {
- Debug.currentAssertionLevel = 0 /* None */;
- Debug.isDebugging = false;
- function shouldAssert(level) {
- return Debug.currentAssertionLevel >= level;
- }
- Debug.shouldAssert = shouldAssert;
- function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
- if (!expression) {
- if (verboseDebugInfo) {
- message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
- }
- fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
- }
- }
- Debug.assert = assert;
- function assertEqual(a, b, msg, msg2) {
- if (a !== b) {
- var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
- fail("Expected " + a + " === " + b + ". " + message);
- }
- }
- Debug.assertEqual = assertEqual;
- function assertLessThan(a, b, msg) {
- if (a >= b) {
- fail("Expected " + a + " < " + b + ". " + (msg || ""));
- }
- }
- Debug.assertLessThan = assertLessThan;
- function assertLessThanOrEqual(a, b) {
- if (a > b) {
- fail("Expected " + a + " <= " + b);
- }
- }
- Debug.assertLessThanOrEqual = assertLessThanOrEqual;
- function assertGreaterThanOrEqual(a, b) {
- if (a < b) {
- fail("Expected " + a + " >= " + b);
- }
- }
- Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
- function fail(message, stackCrawlMark) {
- debugger;
- var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
- if (Error.captureStackTrace) {
- Error.captureStackTrace(e, stackCrawlMark || fail);
- }
- throw e;
- }
- Debug.fail = fail;
- function assertDefined(value, message) {
- if (value === undefined || value === null)
- return fail(message);
- return value;
- }
- Debug.assertDefined = assertDefined;
- function assertEachDefined(value, message) {
- for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
- var v = value_1[_i];
- assertDefined(v, message);
- }
- return value;
- }
- Debug.assertEachDefined = assertEachDefined;
- function assertNever(member, message, stackCrawlMark) {
- if (message === void 0) { message = "Illegal value:"; }
- var detail = typeof member === "object" && "kind" in member && "pos" in member ? "SyntaxKind: " + Debug.showSyntaxKind(member) : JSON.stringify(member);
- return fail(message + " " + detail, stackCrawlMark || assertNever);
- }
- Debug.assertNever = assertNever;
- function getFunctionName(func) {
- if (typeof func !== "function") {
- return "";
- }
- else if (func.hasOwnProperty("name")) {
- return func.name;
- }
- else {
- var text = Function.prototype.toString.call(func);
- var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
- return match ? match[1] : "";
- }
- }
- Debug.getFunctionName = getFunctionName;
- })(Debug = ts.Debug || (ts.Debug = {}));
function equateValues(a, b) {
return a === b;
}
@@ -1832,7 +1746,7 @@ var ts;
bestCandidate = candidate;
}
else {
- Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
+ ts.Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
bestDistance = distance;
bestCandidate = candidate;
}
@@ -1976,7 +1890,7 @@ var ts;
* E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar"
*/
function matchedText(pattern, candidate) {
- Debug.assert(isPatternMatch(pattern, candidate));
+ ts.Debug.assert(isPatternMatch(pattern, candidate));
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
}
ts.matchedText = matchedText;
@@ -2095,6 +2009,242 @@ var ts;
}
}
})(ts || (ts = {}));
+/* @internal */
+var ts;
+(function (ts) {
+ var Debug;
+ (function (Debug) {
+ Debug.currentAssertionLevel = 0 /* None */;
+ Debug.isDebugging = false;
+ function shouldAssert(level) {
+ return Debug.currentAssertionLevel >= level;
+ }
+ Debug.shouldAssert = shouldAssert;
+ function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
+ if (!expression) {
+ if (verboseDebugInfo) {
+ message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
+ }
+ fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
+ }
+ }
+ Debug.assert = assert;
+ function assertEqual(a, b, msg, msg2) {
+ if (a !== b) {
+ var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
+ fail("Expected " + a + " === " + b + ". " + message);
+ }
+ }
+ Debug.assertEqual = assertEqual;
+ function assertLessThan(a, b, msg) {
+ if (a >= b) {
+ fail("Expected " + a + " < " + b + ". " + (msg || ""));
+ }
+ }
+ Debug.assertLessThan = assertLessThan;
+ function assertLessThanOrEqual(a, b) {
+ if (a > b) {
+ fail("Expected " + a + " <= " + b);
+ }
+ }
+ Debug.assertLessThanOrEqual = assertLessThanOrEqual;
+ function assertGreaterThanOrEqual(a, b) {
+ if (a < b) {
+ fail("Expected " + a + " >= " + b);
+ }
+ }
+ Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
+ function fail(message, stackCrawlMark) {
+ debugger;
+ var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(e, stackCrawlMark || fail);
+ }
+ throw e;
+ }
+ Debug.fail = fail;
+ function assertDefined(value, message) {
+ if (value === undefined || value === null)
+ return fail(message);
+ return value;
+ }
+ Debug.assertDefined = assertDefined;
+ function assertEachDefined(value, message) {
+ for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
+ var v = value_1[_i];
+ assertDefined(v, message);
+ }
+ return value;
+ }
+ Debug.assertEachDefined = assertEachDefined;
+ function assertNever(member, message, stackCrawlMark) {
+ if (message === void 0) { message = "Illegal value:"; }
+ var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
+ return fail(message + " " + detail, stackCrawlMark || assertNever);
+ }
+ Debug.assertNever = assertNever;
+ function getFunctionName(func) {
+ if (typeof func !== "function") {
+ return "";
+ }
+ else if (func.hasOwnProperty("name")) {
+ return func.name;
+ }
+ else {
+ var text = Function.prototype.toString.call(func);
+ var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
+ return match ? match[1] : "";
+ }
+ }
+ Debug.getFunctionName = getFunctionName;
+ function formatSymbol(symbol) {
+ return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
+ }
+ Debug.formatSymbol = formatSymbol;
+ /**
+ * Formats an enum value as a string for debugging and debug assertions.
+ */
+ function formatEnum(value, enumObject, isFlags) {
+ if (value === void 0) { value = 0; }
+ var members = getEnumMembers(enumObject);
+ if (value === 0) {
+ return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
+ }
+ if (isFlags) {
+ var result = "";
+ var remainingFlags = value;
+ for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
+ var _a = members[i], enumValue = _a[0], enumName = _a[1];
+ if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
+ remainingFlags &= ~enumValue;
+ result = "" + enumName + (result ? "|" : "") + result;
+ }
+ }
+ if (remainingFlags === 0) {
+ return result;
+ }
+ }
+ else {
+ for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
+ var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
+ if (enumValue === value) {
+ return enumName;
+ }
+ }
+ }
+ return value.toString();
+ }
+ Debug.formatEnum = formatEnum;
+ function getEnumMembers(enumObject) {
+ var result = [];
+ for (var name in enumObject) {
+ var value = enumObject[name];
+ if (typeof value === "number") {
+ result.push([value, name]);
+ }
+ }
+ return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
+ }
+ function formatSyntaxKind(kind) {
+ return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
+ }
+ Debug.formatSyntaxKind = formatSyntaxKind;
+ function formatNodeFlags(flags) {
+ return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
+ }
+ Debug.formatNodeFlags = formatNodeFlags;
+ function formatModifierFlags(flags) {
+ return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
+ }
+ Debug.formatModifierFlags = formatModifierFlags;
+ function formatTransformFlags(flags) {
+ return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
+ }
+ Debug.formatTransformFlags = formatTransformFlags;
+ function formatEmitFlags(flags) {
+ return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
+ }
+ Debug.formatEmitFlags = formatEmitFlags;
+ function formatSymbolFlags(flags) {
+ return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
+ }
+ Debug.formatSymbolFlags = formatSymbolFlags;
+ function formatTypeFlags(flags) {
+ return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
+ }
+ Debug.formatTypeFlags = formatTypeFlags;
+ function formatObjectFlags(flags) {
+ return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
+ }
+ Debug.formatObjectFlags = formatObjectFlags;
+ function failBadSyntaxKind(node, message) {
+ return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
+ }
+ Debug.failBadSyntaxKind = failBadSyntaxKind;
+ Debug.assertEachNode = shouldAssert(1 /* Normal */)
+ ? function (nodes, test, message) { return assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertEachNode); }
+ : ts.noop;
+ Debug.assertNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); }
+ : ts.noop;
+ Debug.assertOptionalNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
+ : ts.noop;
+ Debug.assertOptionalToken = shouldAssert(1 /* Normal */)
+ ? function (node, kind, message) { return assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
+ : ts.noop;
+ Debug.assertMissingNode = shouldAssert(1 /* Normal */)
+ ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
+ : ts.noop;
+ var isDebugInfoEnabled = false;
+ /**
+ * Injects debug information into frequently used types.
+ */
+ function enableDebugInfo() {
+ if (isDebugInfoEnabled)
+ return;
+ // Add additional properties in debug mode to assist with debugging.
+ Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
+ __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
+ });
+ Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
+ __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
+ __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } },
+ __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
+ });
+ var nodeConstructors = [
+ ts.objectAllocator.getNodeConstructor(),
+ ts.objectAllocator.getIdentifierConstructor(),
+ ts.objectAllocator.getTokenConstructor(),
+ ts.objectAllocator.getSourceFileConstructor()
+ ];
+ for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
+ var ctor = nodeConstructors_1[_i];
+ if (!ctor.prototype.hasOwnProperty("__debugKind")) {
+ Object.defineProperties(ctor.prototype, {
+ __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
+ __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
+ __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
+ __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
+ __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
+ __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
+ __debugGetText: {
+ value: function (includeTrivia) {
+ if (ts.nodeIsSynthesized(this))
+ return "";
+ var parseNode = ts.getParseTreeNode(this);
+ var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
+ return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
+ }
+ }
+ });
+ }
+ }
+ isDebugInfoEnabled = true;
+ }
+ Debug.enableDebugInfo = enableDebugInfo;
+ })(Debug = ts.Debug || (ts.Debug = {}));
+})(ts || (ts = {}));
/*@internal*/
var ts;
(function (ts) {
@@ -5323,7 +5473,7 @@ var ts;
Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."),
Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
- Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", "Cannot compile namespaces when the '--isolatedModules' flag is provided."),
+ All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."),
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."),
A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
@@ -6110,7 +6260,6 @@ var ts;
Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."),
Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
Multiple_consecutive_numeric_separators_are_not_permitted: diag(6189, ts.DiagnosticCategory.Error, "Multiple_consecutive_numeric_separators_are_not_permitted_6189", "Multiple consecutive numeric separators are not permitted."),
- Found_package_json_at_0_Package_ID_is_1: diag(6190, ts.DiagnosticCategory.Message, "Found_package_json_at_0_Package_ID_is_1_6190", "Found 'package.json' at '{0}'. Package ID is '{1}'."),
Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: diag(6191, ts.DiagnosticCategory.Message, "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191", "Whether to keep outdated console output in watch mode instead of clearing the screen."),
All_imports_in_import_declaration_are_unused: diag(6192, ts.DiagnosticCategory.Error, "All_imports_in_import_declaration_are_unused_6192", "All imports in import declaration are unused.", /*reportsUnnecessary*/ true),
Found_1_error_Watching_for_file_changes: diag(6193, ts.DiagnosticCategory.Message, "Found_1_error_Watching_for_file_changes_6193", "Found 1 error. Watching for file changes."),
@@ -6137,6 +6286,9 @@ var ts;
Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."),
Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
+ Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"),
+ Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"),
+ package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."),
Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
@@ -6226,6 +6378,8 @@ var ts;
_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."),
Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1: diag(7051, ts.DiagnosticCategory.Error, "Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1_7051", "Parameter has a name but no type. Did you mean '{0}: {1}'?"),
Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1: diag(7052, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1_7052", "Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}' ?"),
+ Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: diag(7053, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053", "Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'."),
+ No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1: diag(7054, ts.DiagnosticCategory.Error, "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054", "No index signature with a parameter of type '{0}' was found on type '{1}'."),
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."),
@@ -10299,7 +10453,7 @@ var ts;
}
ts.isFunctionSymbol = isFunctionSymbol;
function importFromModuleSpecifier(node) {
- return tryGetImportFromModuleSpecifier(node) || ts.Debug.fail(ts.Debug.showSyntaxKind(node.parent));
+ return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
}
ts.importFromModuleSpecifier = importFromModuleSpecifier;
function tryGetImportFromModuleSpecifier(node) {
@@ -12254,77 +12408,6 @@ var ts;
return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
- /**
- * Formats an enum value as a string for debugging and debug assertions.
- */
- function formatEnum(value, enumObject, isFlags) {
- if (value === void 0) { value = 0; }
- var members = getEnumMembers(enumObject);
- if (value === 0) {
- return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
- }
- if (isFlags) {
- var result = "";
- var remainingFlags = value;
- for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
- var _a = members[i], enumValue = _a[0], enumName = _a[1];
- if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
- remainingFlags &= ~enumValue;
- result = "" + enumName + (result ? ", " : "") + result;
- }
- }
- if (remainingFlags === 0) {
- return result;
- }
- }
- else {
- for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
- var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
- if (enumValue === value) {
- return enumName;
- }
- }
- }
- return value.toString();
- }
- function getEnumMembers(enumObject) {
- var result = [];
- for (var name in enumObject) {
- var value = enumObject[name];
- if (typeof value === "number") {
- result.push([value, name]);
- }
- }
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
- }
- function formatSyntaxKind(kind) {
- return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
- }
- ts.formatSyntaxKind = formatSyntaxKind;
- function formatModifierFlags(flags) {
- return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
- }
- ts.formatModifierFlags = formatModifierFlags;
- function formatTransformFlags(flags) {
- return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
- }
- ts.formatTransformFlags = formatTransformFlags;
- function formatEmitFlags(flags) {
- return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
- }
- ts.formatEmitFlags = formatEmitFlags;
- function formatSymbolFlags(flags) {
- return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
- }
- ts.formatSymbolFlags = formatSymbolFlags;
- function formatTypeFlags(flags) {
- return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
- }
- ts.formatTypeFlags = formatTypeFlags;
- function formatObjectFlags(flags) {
- return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
- }
- ts.formatObjectFlags = formatObjectFlags;
/**
* Creates a new TextRange from the provided pos and end.
*
@@ -15518,6 +15601,15 @@ var ts;
return root + pathComponents.slice(1).join(ts.directorySeparator);
}
ts.getPathFromPathComponents = getPathFromPathComponents;
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
+ }
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
+ function getPathWithoutRoot(pathComponents) {
+ if (pathComponents.length === 0)
+ return "";
+ return pathComponents.slice(1).join(ts.directorySeparator);
+ }
})(ts || (ts = {}));
/* @internal */
(function (ts) {
@@ -15548,7 +15640,7 @@ var ts;
}
ts.getRelativePathFromFile = getRelativePathFromFile;
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
- Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
+ ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
@@ -16192,32 +16284,9 @@ var ts;
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
}
ts.changeAnyExtension = changeAnyExtension;
- var Debug;
- (function (Debug) {
- function showSymbol(symbol) {
- var symbolFlags = ts.SymbolFlags;
- return "{ flags: " + (symbolFlags ? showFlags(symbol.flags, symbolFlags) : symbol.flags) + "; declarations: " + ts.map(symbol.declarations, showSyntaxKind) + " }";
- }
- Debug.showSymbol = showSymbol;
- function showFlags(flags, flagsEnum) {
- var out = [];
- for (var pow = 0; pow <= 30; pow++) {
- var n = 1 << pow;
- if (flags & n) {
- out.push(flagsEnum[n]);
- }
- }
- return out.join("|");
- }
- function showSyntaxKind(node) {
- var syntaxKind = ts.SyntaxKind;
- return syntaxKind ? syntaxKind[node.kind] : node.kind.toString();
- }
- Debug.showSyntaxKind = showSyntaxKind;
- })(Debug = ts.Debug || (ts.Debug = {}));
function tryParsePattern(pattern) {
// This should be verified outside of here and a proper error thrown.
- Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
+ ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
var indexOfStar = pattern.indexOf("*");
return indexOfStar === -1 ? undefined : {
prefix: pattern.substr(0, indexOfStar),
@@ -16246,7 +16315,7 @@ var ts;
*/
function extensionFromPath(path) {
var ext = tryGetExtensionFromPath(path);
- return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension.");
+ return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
}
ts.extensionFromPath = extensionFromPath;
function isAnySupportedFileExtension(path) {
@@ -16318,7 +16387,7 @@ var ts;
ts.matchPatternOrExact = matchPatternOrExact;
function sliceAfter(arr, value) {
var index = arr.indexOf(value);
- Debug.assert(index !== -1);
+ ts.Debug.assert(index !== -1);
return arr.slice(index);
}
ts.sliceAfter = sliceAfter;
@@ -16336,7 +16405,7 @@ var ts;
}
ts.addRelatedInfo = addRelatedInfo;
function minAndMax(arr, getValue) {
- Debug.assert(arr.length !== 0);
+ ts.Debug.assert(arr.length !== 0);
var min = getValue(arr[0]);
var max = min;
for (var i = 1; i < arr.length; i++) {
@@ -25732,7 +25801,7 @@ var ts;
if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) {
extendedConfigPath = extendedConfigPath + ".json";
if (!host.fileExists(extendedConfigPath)) {
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
}
@@ -25743,7 +25812,7 @@ var ts;
if (resolved.resolvedModule) {
return resolved.resolvedModule.resolvedFileName;
}
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
@@ -26258,11 +26327,22 @@ var ts;
return !!compilerOptions.traceResolution && host.trace !== undefined;
}
ts.isTraceEnabled = isTraceEnabled;
- function withPackageId(packageId, r) {
+ function withPackageId(packageInfo, r) {
+ var packageId;
+ if (r && packageInfo) {
+ var packageJsonContent = packageInfo.packageJsonContent;
+ if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
+ packageId = {
+ name: packageJsonContent.name,
+ subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
+ version: packageJsonContent.version
+ };
+ }
+ }
return r && { path: r.path, extension: r.ext, packageId: packageId };
}
function noPackageId(r) {
- return withPackageId(/*packageId*/ undefined, r);
+ return withPackageId(/*packageInfo*/ undefined, r);
}
function removeIgnoredPackageId(r) {
if (r) {
@@ -26314,8 +26394,15 @@ var ts;
}
function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
- if (fileName === undefined)
+ if (fileName === undefined) {
+ return;
+ }
+ if (!fileName) {
+ if (state.traceEnabled) {
+ trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
+ }
return;
+ }
var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
@@ -26468,7 +26555,12 @@ var ts;
var fileName = resolved.fileName, packageId = resolved.packageId;
var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
if (traceEnabled) {
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ if (packageId) {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary);
+ }
+ else {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ }
}
resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
}
@@ -26756,7 +26848,12 @@ var ts;
}
if (traceEnabled) {
if (result.resolvedModule) {
- trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ if (result.resolvedModule.packageId) {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2, moduleName, result.resolvedModule.resolvedFileName, ts.packageIdToString(result.resolvedModule.packageId));
+ }
+ else {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ }
}
else {
trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
@@ -27026,10 +27123,9 @@ var ts;
}
var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
if (resolvedFromFile) {
- var nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
- var packageInfo = nm && getPackageJsonInfo(nm.packageDirectory, nm.subModuleName, /*onlyRecordFailures*/ false, state);
- var packageId = packageInfo && packageInfo.packageId;
- return withPackageId(packageId, resolvedFromFile);
+ var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
+ var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined;
+ return withPackageId(packageInfo, resolvedFromFile);
}
}
if (!onlyRecordFailures) {
@@ -27055,11 +27151,10 @@ var ts;
* (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.)
*
* packageDirectory is the directory of the package itself.
- * subModuleName is the path within the package.
- * For `blah/node_modules/foo/index.d.ts` this is { packageDirectory: "foo", subModuleName: "index.d.ts" }. (Part before "/node_modules/" is ignored.)
- * For `/node_modules/foo/bar.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
- * For `/node_modules/@types/foo/bar/index.d.ts` this is { packageDirectory: "@types/foo", subModuleName: "bar/index.d.ts" }.
- * For `/node_modules/foo/bar/index.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
+ * For `blah/node_modules/foo/index.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/foo/bar.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo"
+ * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo"
*/
function parseNodeModuleFromPath(resolved) {
var path = ts.normalizePath(resolved.path);
@@ -27072,26 +27167,12 @@ var ts;
if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) {
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
}
- var packageDirectory = path.slice(0, indexAfterPackageName);
- var subModuleName = ts.removeExtension(path.slice(indexAfterPackageName + 1), resolved.ext) + ".d.ts" /* Dts */;
- return { packageDirectory: packageDirectory, subModuleName: subModuleName };
+ return path.slice(0, indexAfterPackageName);
}
function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
}
- function addExtensionAndIndex(path) {
- if (path === "") {
- return "index.d.ts";
- }
- if (ts.endsWith(path, ".d.ts")) {
- return path;
- }
- if (path === "index" || ts.endsWith(path, "/index")) {
- return path + ".d.ts";
- }
- return path + "/index.d.ts";
- }
function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
}
@@ -27165,52 +27246,22 @@ var ts;
}
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
if (considerPackageJson === void 0) { considerPackageJson = true; }
- var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, "", onlyRecordFailures, state) : undefined;
- var packageId = packageInfo && packageInfo.packageId;
+ var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
var versionPaths = packageInfo && packageInfo.versionPaths;
- return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
+ return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
}
- function getPackageJsonInfo(packageDirectory, subModuleName, onlyRecordFailures, state) {
+ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
var host = state.host, traceEnabled = state.traceEnabled;
var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
if (directoryExists && host.fileExists(packageJsonPath)) {
var packageJsonContent = ts.readJson(packageJsonPath, host);
- if (subModuleName === "") { // looking up the root - need to handle types/typings/main redirects for subModuleName
- var path = readPackageJsonTypesFields(packageJsonContent, packageDirectory, state);
- if (typeof path === "string") {
- subModuleName = addExtensionAndIndex(path.substring(packageDirectory.length + 1));
- }
- else {
- var jsPath = readPackageJsonMainField(packageJsonContent, packageDirectory, state);
- if (typeof jsPath === "string" && jsPath.length > packageDirectory.length) {
- var potentialSubModule_1 = jsPath.substring(packageDirectory.length + 1);
- subModuleName = (ts.forEach(ts.supportedJSExtensions, function (extension) {
- return ts.tryRemoveExtension(potentialSubModule_1, extension);
- }) || potentialSubModule_1) + ".d.ts" /* Dts */;
- }
- else {
- subModuleName = "index.d.ts";
- }
- }
- }
- if (!ts.endsWith(subModuleName, ".d.ts" /* Dts */)) {
- subModuleName = addExtensionAndIndex(subModuleName);
- }
- var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
- var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string"
- ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version }
- : undefined;
if (traceEnabled) {
- if (packageId) {
- trace(host, ts.Diagnostics.Found_package_json_at_0_Package_ID_is_1, packageJsonPath, ts.packageIdToString(packageId));
- }
- else {
- trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
- }
+ trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
}
- return { packageJsonContent: packageJsonContent, packageId: packageId, versionPaths: versionPaths };
+ var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
+ return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
}
else {
if (directoryExists && traceEnabled) {
@@ -27349,37 +27400,31 @@ var ts;
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
- var packageJsonContent;
- var packageId;
- var versionPaths;
- var packageInfo = getPackageJsonInfo(candidate, "", !nodeModulesDirectoryExists, state);
+ var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
if (packageInfo) {
- (packageJsonContent = packageInfo.packageJsonContent, packageId = packageInfo.packageId, versionPaths = packageInfo.versionPaths);
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
if (fromFile) {
return noPackageId(fromFile);
}
- var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, fromDirectory);
+ var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
+ return withPackageId(packageInfo, fromDirectory);
}
var loader = function (extensions, candidate, onlyRecordFailures, state) {
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
- loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, pathAndExtension);
+ loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
+ return withPackageId(packageInfo, pathAndExtension);
};
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
if (rest !== "") { // If "rest" is empty, we just did this search above.
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
// Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings.
- var packageInfo_1 = getPackageJsonInfo(packageDirectory, rest, !nodeModulesDirectoryExists, state);
- if (packageInfo_1)
- (packageId = packageInfo_1.packageId, versionPaths = packageInfo_1.versionPaths);
- if (versionPaths) {
+ packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
+ if (packageInfo && packageInfo.versionPaths) {
if (state.traceEnabled) {
- trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, rest);
+ trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest);
}
var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, versionPaths.paths, loader, !packageDirectoryExists, state);
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
if (fromPaths) {
return fromPaths.value;
}
@@ -29834,7 +29879,7 @@ var ts;
}
break;
default:
- ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer));
+ ts.Debug.failBadSyntaxKind(thisContainer);
}
}
function bindSpecialPropertyDeclaration(node) {
@@ -29892,7 +29937,7 @@ var ts;
// Fix up parent pointers since we're going to use these nodes before we bind into them
node.left.parent = node;
node.right.parent = node;
- if (ts.isIdentifier(lhs.expression) && container === file && isNameOfExportsOrModuleExportsAliasDeclaration(file, lhs.expression)) {
+ if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) {
// This can be an alias for the 'exports' or 'module.exports' names, e.g.
// var util = module.exports;
// util.property = function ...
@@ -30247,20 +30292,29 @@ var ts;
}
}
function isExportsOrModuleExportsOrAlias(sourceFile, node) {
- return ts.isExportsIdentifier(node) ||
- ts.isModuleExportsPropertyAccessExpression(node) ||
- ts.isIdentifier(node) && isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node);
+ var i = 0;
+ var q = [node];
+ while (q.length && i < 100) {
+ i++;
+ node = q.shift();
+ if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) {
+ return true;
+ }
+ else if (ts.isIdentifier(node)) {
+ var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
+ if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
+ var init = symbol.valueDeclaration.initializer;
+ q.push(init);
+ if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) {
+ q.push(init.left);
+ q.push(init.right);
+ }
+ }
+ }
+ }
+ return false;
}
ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
- function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) {
- var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
- return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) &&
- !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer);
- }
- function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) {
- return isExportsOrModuleExportsOrAlias(sourceFile, node) ||
- (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && (isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.left) || isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.right)));
- }
function lookupSymbolForNameWorker(container, name) {
var local = container.locals && container.locals.get(name);
if (local) {
@@ -31400,6 +31454,10 @@ var ts;
node = ts.getParseTreeNode(node);
return node ? getTypeOfNode(node) : errorType;
},
+ getTypeOfAssignmentPattern: function (nodeIn) {
+ var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
+ return node && getTypeOfAssignmentPattern(node) || errorType;
+ },
getPropertySymbolOfDestructuringAssignment: function (locationIn) {
var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
@@ -34500,7 +34558,7 @@ var ts;
context.approximateLength += 6;
return ts.createKeywordTypeNode(137 /* ObjectKeyword */);
}
- if (type.flags & 262144 /* TypeParameter */ && type.isThisType) {
+ if (isThisTypeParameter(type)) {
if (context.flags & 4194304 /* InObjectTypeLiteral */) {
if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
context.encounteredError = true;
@@ -35190,6 +35248,11 @@ var ts;
function lookupTypeParameterNodes(chain, index, context) {
ts.Debug.assert(chain && 0 <= index && index < chain.length);
var symbol = chain[index];
+ var symbolId = "" + getSymbolId(symbol);
+ if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
+ return undefined;
+ }
+ (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
var typeParameterNodes;
if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) {
var parentSymbol = symbol;
@@ -36130,7 +36193,7 @@ var ts;
return type;
}
else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(declaredType, declaration, type);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
}
}
return declaredType;
@@ -36449,7 +36512,7 @@ var ts;
type = getTypeOfEnumMember(symbol);
}
else {
- return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol));
+ return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
}
if (!popTypeResolution()) {
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
@@ -37719,10 +37782,10 @@ var ts;
// Union the result types when more than one signature matches
if (unionSignatures.length > 1) {
var thisParameter = signature.thisParameter;
- if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) {
- // TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do
+ var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
+ if (firstThisParameterOfUnionSignatures) {
var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */);
- thisParameter = createSymbolWithType(signature.thisParameter, thisType);
+ thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
}
s = createUnionSignature(signature, unionSignatures);
s.thisParameter = thisParameter;
@@ -38288,15 +38351,19 @@ var ts;
function getConstraintOfIndexedAccess(type) {
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
}
+ function getSimplifiedTypeOrConstraint(type) {
+ var simplified = getSimplifiedType(type, /*writing*/ false);
+ return simplified !== type ? simplified : getConstraintOfType(type);
+ }
function getConstraintFromIndexedAccess(type) {
- var indexConstraint = getConstraintOfType(type.indexType);
+ var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
if (indexConstraint && indexConstraint !== type.indexType) {
var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
if (indexedAccess) {
return indexedAccess;
}
}
- var objectConstraint = getConstraintOfType(type.objectType);
+ var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
if (objectConstraint && objectConstraint !== type.objectType) {
return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
}
@@ -40285,6 +40352,14 @@ var ts;
types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
return true;
}
+ function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
+ var result = createType(2097152 /* Intersection */);
+ result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
+ result.types = types;
+ result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
+ result.aliasTypeArguments = aliasTypeArguments;
+ return result;
+ }
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
@@ -40322,30 +40397,36 @@ var ts;
if (typeSet.length === 1) {
return typeSet[0];
}
- if (includes & 1048576 /* Union */) {
- if (intersectUnionsOfPrimitiveTypes(typeSet)) {
- // When the intersection creates a reduced set (which might mean that *all* union types have
- // disappeared), we restart the operation to get a new set of combined flags. Once we have
- // reduced we'll never reduce again, so this occurs at most once.
- return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
- }
- // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
- // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
- var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
- var unionType = typeSet[unionIndex_1];
- return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
- }
var id = getTypeListId(typeSet);
- var type = intersectionTypes.get(id);
- if (!type) {
- type = createType(2097152 /* Intersection */);
- intersectionTypes.set(id, type);
- type.objectFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */);
- type.types = typeSet;
- type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
- type.aliasTypeArguments = aliasTypeArguments;
+ var result = intersectionTypes.get(id);
+ if (!result) {
+ if (includes & 1048576 /* Union */) {
+ if (intersectUnionsOfPrimitiveTypes(typeSet)) {
+ // When the intersection creates a reduced set (which might mean that *all* union types have
+ // disappeared), we restart the operation to get a new set of combined flags. Once we have
+ // reduced we'll never reduce again, so this occurs at most once.
+ result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ else {
+ // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
+ // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
+ // If the estimated size of the resulting union type exceeds 100000 constituents, report an error.
+ var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 /* Union */ ? t.types.length : 1); }, 1);
+ if (size >= 100000) {
+ error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
+ return errorType;
+ }
+ var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
+ var unionType = typeSet[unionIndex_1];
+ result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
+ }
+ }
+ else {
+ result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ intersectionTypes.set(id, result);
}
- return type;
+ return result;
}
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
@@ -40478,7 +40559,7 @@ var ts;
}
return false;
}
- function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, accessNode, accessFlags) {
+ function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined;
var propName = isTypeUsableAsPropertyName(indexType) ?
getPropertyNameFromType(indexType) :
@@ -40516,6 +40597,7 @@ var ts;
error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
}
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */));
return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
}
}
@@ -40537,13 +40619,7 @@ var ts;
error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
return indexInfo.type;
}
- if (indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
- if (accessExpression) {
- error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
- return indexInfo.type;
- }
- return undefined;
- }
+ errorIfWritingToReadonlyIndex(indexInfo);
return indexInfo.type;
}
if (indexType.flags & 131072 /* Never */) {
@@ -40556,7 +40632,7 @@ var ts;
if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) {
error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
- else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
+ else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
}
@@ -40576,7 +40652,25 @@ var ts;
error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion_1);
}
else {
- error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType));
+ var errorInfo = void 0;
+ if (indexType.flags & 1024 /* EnumLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 8192 /* UniqueESSymbol */) {
+ var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 128 /* StringLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & 256 /* NumberLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
+ }
+ errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType));
+ diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
}
}
}
@@ -40603,6 +40697,11 @@ var ts;
return indexType;
}
return undefined;
+ function errorIfWritingToReadonlyIndex(indexInfo) {
+ if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
+ error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
+ }
+ }
}
function getIndexNodeForAccessExpression(accessNode) {
return accessNode.kind === 191 /* ElementAccessExpression */
@@ -40619,6 +40718,9 @@ var ts;
function isGenericIndexType(type) {
return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */);
}
+ function isThisTypeParameter(type) {
+ return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
+ }
function getSimplifiedType(type, writing) {
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
@@ -40754,7 +40856,7 @@ var ts;
var wasMissingProp = false;
for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
var t = _a[_i];
- var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, accessNode, accessFlags);
+ var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
if (propType) {
propTypes.push(propType);
}
@@ -40772,7 +40874,7 @@ var ts;
}
return accessFlags & 2 /* Writing */ ? getIntersectionType(propTypes) : getUnionType(propTypes);
}
- return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, accessNode, accessFlags | 4 /* CacheSymbol */);
+ return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */);
}
function getTypeFromIndexedAccessTypeNode(node) {
var links = getNodeLinks(node);
@@ -43318,8 +43420,7 @@ var ts;
}
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
// simplified form of T or, if T doesn't simplify, the constraint of T.
- var simplified = getSimplifiedType(target.type, /*writing*/ false);
- var constraint = simplified !== target.type ? simplified : getConstraintOfType(target.type);
+ var constraint = getSimplifiedTypeOrConstraint(target.type);
if (constraint) {
// We require Ternary.True here such that circular constraints don't cause
// false positives. For example, given 'T extends { [K in keyof T]: string }',
@@ -46860,7 +46961,7 @@ var ts;
return !assumeTrue;
}
function narrowByInKeyword(type, literal, assumeTrue) {
- if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) {
+ if (type.flags & (1048576 /* Union */ | 524288 /* Object */) || isThisTypeParameter(type)) {
var propName_1 = ts.escapeLeadingUnderscores(literal.text);
return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
}
@@ -48412,8 +48513,8 @@ var ts;
// For a (non-symbol) computed property, there is no reason to look up the name
// in the type. It will just be "__computed", which does not appear in any
// SymbolTable.
- var symbolName_2 = getSymbolOfNode(element).escapedName;
- var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_2);
+ var symbolName_3 = getSymbolOfNode(element).escapedName;
+ var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
if (propertyType) {
return propertyType;
}
@@ -49888,7 +49989,7 @@ var ts;
return anyType;
}
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
- reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType);
+ reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
}
return errorType;
}
@@ -50253,7 +50354,7 @@ var ts;
}
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
var accessFlags = ts.isAssignmentTarget(node) ?
- 2 /* Writing */ | (isGenericObjectType(objectType) ? 1 /* NoIndexSignatures */ : 0) :
+ 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) :
0 /* None */;
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
return checkIndexedAccessIndexType(indexedAccessType, node);
@@ -52833,15 +52934,16 @@ var ts;
if (strictNullChecks && properties.length === 0) {
return checkNonNullType(sourceType, node);
}
- for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
- var p = properties_4[_i];
- checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis);
+ for (var i = 0; i < properties.length; i++) {
+ checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
}
return sourceType;
}
/** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */
- function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) {
+ function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
if (rightIsThis === void 0) { rightIsThis = false; }
+ var properties = node.properties;
+ var property = properties[propertyIndex];
if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) {
var name = property.name;
var exprType = getLiteralTypeFromPropertyName(name);
@@ -52858,18 +52960,26 @@ var ts;
return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
}
else if (property.kind === 278 /* SpreadAssignment */) {
- if (languageVersion < 8 /* ESNext */) {
- checkExternalEmitHelpers(property, 4 /* Rest */);
+ if (propertyIndex < properties.length - 1) {
+ error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
}
- var nonRestNames = [];
- if (allProperties) {
- for (var i = 0; i < allProperties.length - 1; i++) {
- nonRestNames.push(allProperties[i].name);
+ else {
+ if (languageVersion < 8 /* ESNext */) {
+ checkExternalEmitHelpers(property, 4 /* Rest */);
+ }
+ var nonRestNames = [];
+ if (allProperties) {
+ for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
+ var otherProperty = allProperties_1[_i];
+ if (!ts.isSpreadAssignment(otherProperty)) {
+ nonRestNames.push(otherProperty.name);
+ }
+ }
}
+ var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
+ checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
+ return checkDestructuringAssignment(property.expression, type);
}
- var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
- checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
- return checkDestructuringAssignment(property.expression, type);
}
else {
error(property, ts.Diagnostics.Property_assignment_expected);
@@ -54808,7 +54918,7 @@ var ts;
case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591
return 1 /* ExportValue */;
default:
- return ts.Debug.fail(ts.Debug.showSyntaxKind(d));
+ return ts.Debug.failBadSyntaxKind(d);
}
}
}
@@ -55973,7 +56083,7 @@ var ts;
if (type !== errorType && declarationType !== errorType &&
!isTypeIdenticalTo(type, declarationType) &&
!(symbol.flags & 67108864 /* Assignment */)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
}
if (node.initializer) {
checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined);
@@ -55992,12 +56102,16 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) {
+ function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */
? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
: ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
- error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType));
+ var declName = ts.declarationNameToString(nextDeclarationName);
+ var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
+ if (firstDeclaration) {
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
+ }
}
function areDeclarationFlagsIdentical(left, right) {
if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) ||
@@ -57138,8 +57252,8 @@ var ts;
for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
var base = baseTypes_2[_i];
var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
- for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) {
- var prop = properties_5[_a];
+ for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) {
+ var prop = properties_4[_a];
var existing = seen.get(prop.escapedName);
if (!existing) {
seen.set(prop.escapedName, { prop: prop, containingType: base });
@@ -58755,7 +58869,7 @@ var ts;
// }
// [ a ] from
// [a] = [ some array ...]
- function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) {
+ function getTypeOfAssignmentPattern(expr) {
ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */);
// If this is from "for of"
// for ( { a } of elems) {
@@ -58773,15 +58887,17 @@ var ts;
// If this is from nested object binding pattern
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
if (expr.parent.kind === 276 /* PropertyAssignment */) {
- var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent);
- return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217
+ var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
+ var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType;
+ var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent);
+ return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex);
}
// Array literal assignment - array destructuring pattern
- ts.Debug.assert(expr.parent.kind === 188 /* ArrayLiteralExpression */);
+ var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
// [{ property1: p1, property2 }] = elems;
- var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent);
- var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
- return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); // TODO: GH#18217
+ var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
+ var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
+ return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
}
// Gets the property symbol corresponding to the property in destructuring assignment
// 'property1' from
@@ -58791,7 +58907,7 @@ var ts;
// [a] = [ property1, property2 ]
function getPropertySymbolOfDestructuringAssignment(location) {
// Get the type of the object or array literal and then look for property of given name in the type
- var typeOfObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(location.parent.parent);
+ var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
}
function getRegularTypeOfExpression(expr) {
@@ -58957,12 +59073,16 @@ var ts;
}
return undefined;
}
+ function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
+ return ts.isBindingElement(symbol.valueDeclaration)
+ && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */;
+ }
function isSymbolOfDeclarationWithCollidingName(symbol) {
if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) {
var links = getSymbolLinks(symbol);
if (links.isDeclarationWithCollidingName === undefined) {
var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
- if (ts.isStatementWithLocals(container)) {
+ if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) {
// redeclaration - always should be renamed
@@ -64445,7 +64565,7 @@ var ts;
function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
if (property === firstAccessor) {
- var properties_6 = [];
+ var properties_5 = [];
if (getAccessor) {
var getterFunction = ts.createFunctionExpression(getAccessor.modifiers,
/*asteriskToken*/ undefined,
@@ -64456,7 +64576,7 @@ var ts;
ts.setTextRange(getterFunction, getAccessor);
ts.setOriginalNode(getterFunction, getAccessor);
var getter = ts.createPropertyAssignment("get", getterFunction);
- properties_6.push(getter);
+ properties_5.push(getter);
}
if (setAccessor) {
var setterFunction = ts.createFunctionExpression(setAccessor.modifiers,
@@ -64468,15 +64588,15 @@ var ts;
ts.setTextRange(setterFunction, setAccessor);
ts.setOriginalNode(setterFunction, setAccessor);
var setter = ts.createPropertyAssignment("set", setterFunction);
- properties_6.push(setter);
+ properties_5.push(setter);
}
- properties_6.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
- properties_6.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"),
/*typeArguments*/ undefined, [
receiver,
createExpressionForPropertyName(property.name),
- ts.createObjectLiteral(properties_6, multiLine)
+ ts.createObjectLiteral(properties_5, multiLine)
]),
/*location*/ firstAccessor);
return ts.aggregateTransformFlags(expression);
@@ -66455,7 +66575,7 @@ var ts;
* @param nodes The NodeArray.
*/
function liftToBlock(nodes) {
- Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
+ ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
}
ts.liftToBlock = liftToBlock;
@@ -66520,73 +66640,6 @@ var ts;
function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
}
- var Debug;
- (function (Debug) {
- var isDebugInfoEnabled = false;
- function failBadSyntaxKind(node, message) {
- return Debug.fail((message || "Unexpected node.") + "\r\nNode " + ts.formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
- }
- Debug.failBadSyntaxKind = failBadSyntaxKind;
- Debug.assertEachNode = Debug.shouldAssert(1 /* Normal */)
- ? function (nodes, test, message) { return Debug.assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertEachNode); }
- : ts.noop;
- Debug.assertNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertNode); }
- : ts.noop;
- Debug.assertOptionalNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
- : ts.noop;
- Debug.assertOptionalToken = Debug.shouldAssert(1 /* Normal */)
- ? function (node, kind, message) { return Debug.assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was not a '" + ts.formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
- : ts.noop;
- Debug.assertMissingNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, message) { return Debug.assert(node === undefined, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
- : ts.noop;
- /**
- * Injects debug information into frequently used types.
- */
- function enableDebugInfo() {
- if (isDebugInfoEnabled)
- return;
- // Add additional properties in debug mode to assist with debugging.
- Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatSymbolFlags(this.flags); } }
- });
- Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } },
- __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } },
- __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
- });
- var nodeConstructors = [
- ts.objectAllocator.getNodeConstructor(),
- ts.objectAllocator.getIdentifierConstructor(),
- ts.objectAllocator.getTokenConstructor(),
- ts.objectAllocator.getSourceFileConstructor()
- ];
- for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
- var ctor = nodeConstructors_1[_i];
- if (!ctor.prototype.hasOwnProperty("__debugKind")) {
- Object.defineProperties(ctor.prototype, {
- __debugKind: { get: function () { return ts.formatSyntaxKind(this.kind); } },
- __debugModifierFlags: { get: function () { return ts.formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
- __debugTransformFlags: { get: function () { return ts.formatTransformFlags(this.transformFlags); } },
- __debugEmitFlags: { get: function () { return ts.formatEmitFlags(ts.getEmitFlags(this)); } },
- __debugGetText: {
- value: function (includeTrivia) {
- if (ts.nodeIsSynthesized(this))
- return "";
- var parseNode = ts.getParseTreeNode(this);
- var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
- return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
- }
- }
- });
- }
- }
- isDebugInfoEnabled = true;
- }
- Debug.enableDebugInfo = enableDebugInfo;
- })(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
/* @internal */
var ts;
@@ -68962,8 +69015,8 @@ var ts;
* @param receiver The receiver on which each property should be assigned.
*/
function addInitializedPropertyStatements(statements, properties, receiver) {
- for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
- var property = properties_7[_i];
+ for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) {
+ var property = properties_6[_i];
var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver));
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
ts.setCommentRange(statement, property);
@@ -68979,8 +69032,8 @@ var ts;
*/
function generateInitializedPropertyExpressions(properties, receiver) {
var expressions = [];
- for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
- var property = properties_8[_i];
+ for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
+ var property = properties_7[_i];
var expression = transformInitializedProperty(property, receiver);
ts.startOnNewLine(expression);
ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
@@ -71522,6 +71575,8 @@ var ts;
return visitObjectLiteralExpression(node);
case 205 /* BinaryExpression */:
return visitBinaryExpression(node, noDestructuringValue);
+ case 275 /* CatchClause */:
+ return visitCatchClause(node);
case 238 /* VariableDeclaration */:
return visitVariableDeclaration(node);
case 228 /* ForOfStatement */:
@@ -71658,6 +71713,23 @@ var ts;
}
return ts.visitEachChild(node, visitor, context);
}
+ function visitCatchClause(node) {
+ if (node.variableDeclaration &&
+ ts.isBindingPattern(node.variableDeclaration.name) &&
+ node.variableDeclaration.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) {
+ var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
+ var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*type*/ undefined, name);
+ var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
+ var block = ts.visitNode(node.block, visitor, ts.isBlock);
+ if (ts.some(visitedBindings)) {
+ block = ts.updateBlock(block, [
+ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings)
+ ].concat(block.statements));
+ }
+ return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block);
+ }
+ return ts.visitEachChild(node, visitor, context);
+ }
/**
* Visits a VariableDeclaration node with a binding pattern.
*
@@ -72801,62 +72873,63 @@ var ts;
HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block";
HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement";
HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock";
- HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement";
- HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper";
+ HierarchyFacts[HierarchyFacts["IterationContainer"] = 1024] = "IterationContainer";
+ HierarchyFacts[HierarchyFacts["ForStatement"] = 2048] = "ForStatement";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 4096] = "ForInOrForOfStatement";
+ HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 8192] = "ConstructorWithCapturedSuper";
// NOTE: do not add more ancestor flags without also updating AncestorFactsMask below.
// NOTE: when adding a new ancestor flag, be sure to update the subtree flags below.
//
// Ancestor masks
//
- HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 8191] = "AncestorFactsMask";
+ HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask";
// We are always in *some* kind of block scope, but only specific block-scope containers are
// top-level or Blocks.
HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes";
- HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes";
+ HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 7104] = "BlockScopeExcludes";
// A source file is a top-level block scope.
HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes";
- HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes";
+ HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 8064] = "SourceFileExcludes";
// Functions, methods, and accessors are both new lexical scopes and new block scopes.
HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes";
- HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 8094] = "FunctionExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes";
HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes";
- HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 8086] = "AsyncFunctionBodyExcludes";
+ HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes";
// Arrow functions are lexically scoped to their container, but are new block scopes.
HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes";
- HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 8064] = "ArrowFunctionExcludes";
+ HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 15232] = "ArrowFunctionExcludes";
// Constructors are both new lexical scopes and new block scopes. Constructors are also
// always considered non-static members of a class.
HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes";
- HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 8086] = "ConstructorExcludes";
+ HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes";
// 'do' and 'while' statements are not block scopes. We track that the subtree is contained
// within an IterationStatement to indicate whether the embedded statement is an
// IterationStatementBlock.
- HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes";
+ HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 1280] = "DoOrWhileStatementIncludes";
HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes";
// 'for' statements are new block scopes and have special handling for 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 3328] = "ForStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 5056] = "ForStatementExcludes";
// 'for-in' and 'for-of' statements are new block scopes and have special handling for
// 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 5376] = "ForInOrForOfStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 3008] = "ForInOrForOfStatementExcludes";
// Blocks (other than function bodies) are new block scopes.
HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes";
- HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes";
+ HierarchyFacts[HierarchyFacts["BlockExcludes"] = 6976] = "BlockExcludes";
HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes";
- HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes";
+ HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 7104] = "IterationStatementBlockExcludes";
//
// Subtree facts
//
- HierarchyFacts[HierarchyFacts["NewTarget"] = 8192] = "NewTarget";
- HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 16384] = "CapturedLexicalThis";
+ HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget";
+ HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 32768] = "CapturedLexicalThis";
//
// Subtree masks
//
- HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -8192] = "SubtreeFactsMask";
+ HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask";
HierarchyFacts[HierarchyFacts["ArrowFunctionSubtreeExcludes"] = 0] = "ArrowFunctionSubtreeExcludes";
- HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 24576] = "FunctionSubtreeExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 49152] = "FunctionSubtreeExcludes";
})(HierarchyFacts || (HierarchyFacts = {}));
function transformES2015(context) {
var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
@@ -72905,7 +72978,7 @@ var ts;
*/
function enterSubtree(excludeFacts, includeFacts) {
var ancestorFacts = hierarchyFacts;
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 8191 /* AncestorFactsMask */;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */;
return ancestorFacts;
}
/**
@@ -72916,17 +72989,17 @@ var ts;
* @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated.
*/
function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -8192 /* SubtreeFactsMask */ | ancestorFacts;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts;
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
- return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0
+ return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0
&& node.kind === 231 /* ReturnStatement */
&& !node.expression;
}
function shouldVisitNode(node) {
return (node.transformFlags & 128 /* ContainsES2015 */) !== 0
|| convertedLoopState !== undefined
- || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
+ || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
|| (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node))
|| (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0;
}
@@ -73043,7 +73116,7 @@ var ts;
}
}
function visitSourceFile(node) {
- var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
+ var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
var prologue = [];
var statements = [];
startLexicalEnvironment();
@@ -73070,7 +73143,7 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitCaseBlock(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -73097,7 +73170,7 @@ var ts;
}
function visitThisKeyword(node) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
if (convertedLoopState) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
@@ -73340,7 +73413,7 @@ var ts;
function addConstructor(statements, node, extendsClauseElement) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8086 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
+ var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
var constructor = ts.getFirstConstructorWithBody(node);
var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
var constructorFunction = ts.createFunctionDeclaration(
@@ -73354,7 +73427,7 @@ var ts;
ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */);
}
statements.push(constructorFunction);
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
}
/**
@@ -73447,7 +73520,7 @@ var ts;
}
}
if (superCallExpression) {
- hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */;
+ hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
}
// visit the remaining statements
@@ -73751,7 +73824,7 @@ var ts;
* @param node A node.
*/
function insertCaptureThisForNodeIfNeeded(statements, node) {
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
insertCaptureThisForNode(statements, node, ts.createThis());
return true;
}
@@ -73769,7 +73842,7 @@ var ts;
ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
}
function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
- if (hierarchyFacts & 8192 /* NewTarget */) {
+ if (hierarchyFacts & 16384 /* NewTarget */) {
var newTarget = void 0;
switch (node.kind) {
case 198 /* ArrowFunction */:
@@ -73939,11 +74012,11 @@ var ts;
*/
function visitArrowFunction(node) {
if (node.transformFlags & 2048 /* ContainsLexicalThis */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8064 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
+ var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
var func = ts.createFunctionExpression(
/*modifiers*/ undefined,
/*asteriskToken*/ undefined,
@@ -73953,7 +74026,7 @@ var ts;
ts.setTextRange(func, node);
ts.setOriginalNode(func, node);
ts.setEmitFlags(func, 8 /* CapturesThis */);
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */) {
enableSubstitutionsForCapturedThis();
}
// If an arrow function contains
@@ -73968,16 +74041,16 @@ var ts;
*/
function visitFunctionExpression(node) {
var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */
- ? enterSubtree(8086 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionExpression(node,
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -73992,13 +74065,13 @@ var ts;
function visitFunctionDeclaration(node) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionDeclaration(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name,
@@ -74016,14 +74089,14 @@ var ts;
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */)
- ? enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- if (hierarchyFacts & 8192 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
+ if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
name = ts.getGeneratedNameForNode(node);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -74118,8 +74191,8 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */
- ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
- : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */);
+ ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
+ : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -74302,11 +74375,11 @@ var ts;
&& isDeclaredInLoop
&& (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0);
var emitExplicitInitializer = !emittedAsTopLevel
- && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0
+ && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0
&& (!resolver.isDeclarationWithCollidingName(node)
|| (isDeclaredInLoop
&& !isCapturedInFunction
- && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0));
+ && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0));
return emitExplicitInitializer;
}
/**
@@ -74377,21 +74450,21 @@ var ts;
}
function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
- var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert);
+ var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
}
function visitDoOrWhileStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
}
function visitForStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement);
}
function visitForInStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
}
function visitForOfStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
}
function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
var statements = [];
@@ -74499,7 +74572,7 @@ var ts;
ts.setTextRange(forStatement, node);
return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
}
- function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) {
+ function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined);
var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined);
@@ -74510,9 +74583,13 @@ var ts;
var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []);
hoistVariableDeclaration(errorRecord);
hoistVariableDeclaration(returnMethod);
+ // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration
+ var initializer = ancestorFacts & 1024 /* IterationContainer */
+ ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
+ : values;
var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(
/*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
- ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression),
+ ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, initializer), node.expression),
ts.createVariableDeclaration(result, /*type*/ undefined, next)
]), node.expression), 2097152 /* NoHoisting */),
/*condition*/ ts.createLogicalNot(ts.createPropertyAccess(result, "done")),
@@ -74623,7 +74700,7 @@ var ts;
}
}
}
- function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) {
+ function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
if (!shouldConvertIterationStatement(node)) {
var saveAllowedNonLabeledJumps = void 0;
if (convertedLoopState) {
@@ -74633,7 +74710,7 @@ var ts;
convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */;
}
var result = convert
- ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined)
+ ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts)
: ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
if (convertedLoopState) {
convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
@@ -74658,7 +74735,7 @@ var ts;
var loop;
if (bodyFunction) {
if (convert) {
- loop = convert(node, outermostLabeledStatement, bodyFunction.part);
+ loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
}
else {
var clone_3 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, /*multiLine*/ true));
@@ -75176,7 +75253,7 @@ var ts;
return expression;
}
function visitCatchClause(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated;
ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
if (ts.isBindingPattern(node.variableDeclaration.name)) {
@@ -75224,7 +75301,7 @@ var ts;
ts.Debug.assert(!ts.isComputedPropertyName(node.name));
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var updated;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
@@ -75234,7 +75311,7 @@ var ts;
else {
updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return updated;
}
@@ -75720,7 +75797,7 @@ var ts;
}
function visitMetaProperty(node) {
if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") {
- hierarchyFacts |= 8192 /* NewTarget */;
+ hierarchyFacts |= 16384 /* NewTarget */;
return ts.createFileLevelUniqueName("_newTarget");
}
return node;
@@ -75735,7 +75812,7 @@ var ts;
function onEmitNode(hint, node, emitCallback) {
if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) {
// If we are tracking a captured `this`, keep track of the enclosing function.
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
? 65 /* FunctionIncludes */ | 16 /* CapturesThis */
: 65 /* FunctionIncludes */);
previousOnEmitNode(hint, node, emitCallback);
@@ -87669,6 +87746,8 @@ var ts;
case 159 /* GetAccessor */:
case 160 /* SetAccessor */:
return generateNameForMethodOrAccessor(node);
+ case 150 /* ComputedPropertyName */:
+ return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true);
default:
return makeTempVariableName(0 /* Auto */);
}
@@ -90360,7 +90439,10 @@ var ts;
if (isRedirect) {
inputName = getProjectReferenceRedirect(fileName) || fileName;
}
- if (ts.getNormalizedAbsolutePath(checkedName, currentDirectory) !== ts.getNormalizedAbsolutePath(inputName, currentDirectory)) {
+ // Check if it differs only in drive letters its ok to ignore that error:
+ var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
+ var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory);
+ if (checkedAbsolutePath !== inputAbsolutePath) {
reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd);
}
}
@@ -90896,10 +90978,10 @@ var ts;
if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
}
- var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
+ var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
@@ -93300,11 +93382,11 @@ var ts;
}
function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
var result = ts.createMap();
- var symlinks = ts.mapDefined(files, function (sf) {
- return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) {
+ var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
+ return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
- });
- });
+ })));
+ }));
for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];
@@ -99034,7 +99116,7 @@ var ts;
var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of.
var entries = pathCompletions.map(function (_a) {
var name = _a.name, kind = _a.kind, span = _a.span, extension = _a.extension;
- return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: "0", replacementSpan: span });
+ return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: Completions.SortText.LocationPriority, replacementSpan: span });
});
return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
}
@@ -99637,6 +99719,14 @@ var ts;
(function (ts) {
var Completions;
(function (Completions) {
+ var SortText;
+ (function (SortText) {
+ SortText["LocationPriority"] = "0";
+ SortText["SuggestedClassMembers"] = "1";
+ SortText["GlobalsOrKeywords"] = "2";
+ SortText["AutoImportSuggestions"] = "3";
+ SortText["JavascriptIdentifiers"] = "4";
+ })(SortText = Completions.SortText || (Completions.SortText = {}));
var SymbolOriginInfoKind;
(function (SymbolOriginInfoKind) {
SymbolOriginInfoKind[SymbolOriginInfoKind["ThisType"] = 0] = "ThisType";
@@ -99671,8 +99761,9 @@ var ts;
var typeChecker = program.getTypeChecker();
var compilerOptions = program.getCompilerOptions();
var contextToken = ts.findPrecedingToken(position, sourceFile);
- if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position))
+ if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) {
return undefined;
+ }
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences);
if (stringCompletions) {
return stringCompletions;
@@ -99705,7 +99796,7 @@ var ts;
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries };
}
function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) {
- var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression;
+ var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap;
if (location && location.parent && ts.isJsxClosingElement(location.parent)) {
// In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag,
// instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element.
@@ -99719,20 +99810,20 @@ var ts;
name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"),
kind: "class" /* classElement */,
kindModifiers: undefined,
- sortText: "0",
+ sortText: SortText.LocationPriority,
};
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [entry] };
}
var entries = [];
if (isUncheckedFile(sourceFile, compilerOptions)) {
- var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap);
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217
}
else {
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
return undefined;
}
- getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap);
+ getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
}
if (keywordFilters !== 0 /* None */) {
var entryNames = ts.arrayToSet(entries, function (e) { return e.name; });
@@ -99774,7 +99865,7 @@ var ts;
name: realName,
kind: "warning" /* warning */,
kindModifiers: "",
- sortText: "1"
+ sortText: SortText.JavascriptIdentifiers
});
}
});
@@ -99783,14 +99874,9 @@ var ts;
return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal);
};
function createCompletionEntryForLiteral(literal) {
- return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: "0" };
+ return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
}
- function createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
- var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
- if (!info) {
- return undefined;
- }
- var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
+ function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
var insertText;
var replacementSpan;
if (origin && origin.kind === 0 /* ThisType */) {
@@ -99827,7 +99913,7 @@ var ts;
name: name,
kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol),
- sortText: "0",
+ sortText: sortText,
source: getSourceFromOrigin(origin),
hasAction: trueOrUndefined(!!origin && originIsExport(origin)),
isRecommended: trueOrUndefined(isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker)),
@@ -99845,7 +99931,7 @@ var ts;
function getSourceFromOrigin(origin) {
return origin && originIsExport(origin) ? ts.stripQuotes(origin.moduleSymbol.name) : undefined;
}
- function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap) {
+ function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) {
var start = ts.timestamp();
// Tracks unique names.
// We don't set this for global variables or completions from external module exports, because we can have multiple of those.
@@ -99855,14 +99941,18 @@ var ts;
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
var symbol = symbols_1[_i];
var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined;
- var entry = createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
- if (!entry) {
+ var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
+ if (!info) {
continue;
}
- var name = entry.name;
+ var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
if (uniques.has(name)) {
continue;
}
+ var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
+ if (!entry) {
+ continue;
+ }
// Latter case tests whether this is a global variable.
if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { // TODO: GH#18217
uniques.set(name, true);
@@ -99895,7 +99985,7 @@ var ts;
name: name,
kindModifiers: "" /* none */,
kind: "label" /* label */,
- sortText: "0"
+ sortText: SortText.LocationPriority
});
}
}
@@ -100272,6 +100362,7 @@ var ts;
var keywordFilters = 0 /* None */;
var symbols = [];
var symbolToOriginInfoMap = [];
+ var symbolToSortTextMap = [];
if (isRightOfDot) {
getTypeScriptMemberSymbols();
}
@@ -100317,7 +100408,8 @@ var ts;
recommendedCompletion: recommendedCompletion,
previousToken: previousToken,
isJsxInitializer: isJsxInitializer,
- insideJsDocTagTypeExpression: insideJsDocTagTypeExpression
+ insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
+ symbolToSortTextMap: symbolToSortTextMap
};
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
@@ -100499,14 +100591,22 @@ var ts;
var isTypeOnly = isTypeOnlyCompletion();
var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined");
+ for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
+ var symbol = symbols_2[_i];
+ if (!typeChecker.isArgumentsSymbol(symbol) &&
+ !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords;
+ }
+ }
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) {
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
if (thisType) {
- for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
- var symbol = _a[_i];
+ for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
+ var symbol = _b[_a];
symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ };
symbols.push(symbol);
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers;
}
}
}
@@ -100625,6 +100725,7 @@ var ts;
// So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`.
ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) {
symbols.push(resolvedModuleSymbol);
+ symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions;
symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false };
}
for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) {
@@ -100649,6 +100750,7 @@ var ts;
var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport };
if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) {
symbols.push(symbol);
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions;
symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin;
}
}
@@ -101285,7 +101387,7 @@ var ts;
name: ts.tokenToString(i),
kind: "keyword" /* keyword */,
kindModifiers: "" /* none */,
- sortText: "0"
+ sortText: SortText.GlobalsOrKeywords
});
}
return res;
@@ -102136,7 +102238,7 @@ var ts;
directImports.push(direct);
break;
default:
- ts.Debug.assertNever(direct, "Unexpected import kind: " + ts.Debug.showSyntaxKind(direct));
+ ts.Debug.failBadSyntaxKind(direct, "Unexpected import kind.");
}
}
}
@@ -102479,7 +102581,7 @@ var ts;
var sym = useLhsSymbol ? checker.getSymbolAtLocation(ts.cast(node.left, ts.isPropertyAccessExpression).name) : symbol;
// Better detection for GH#20803
if (sym && !(checker.getMergedSymbol(sym.parent).flags & 1536 /* Module */)) {
- ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.showSymbol(sym) + ", parent is " + ts.Debug.showSymbol(sym.parent));
+ ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.formatSymbol(sym) + ", parent is " + ts.Debug.formatSymbol(sym.parent));
}
return sym && exportInfo(sym, kind);
}
@@ -103179,7 +103281,7 @@ var ts;
if (symbol.flags & 33554432 /* Transient */)
return undefined;
// Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here.
- ts.Debug.fail("Unexpected symbol at " + ts.Debug.showSyntaxKind(node) + ": " + ts.Debug.showSymbol(symbol));
+ ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol));
}
return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent)
? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name)
@@ -103284,8 +103386,8 @@ var ts;
var sourceId = ts.getNodeId(sourceFile);
var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = ts.createMap());
var anyNewSymbols = false;
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
- var sym = symbols_2[_i];
+ for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) {
+ var sym = symbols_3[_i];
anyNewSymbols = ts.addToSeen(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
}
return anyNewSymbols;
@@ -107744,8 +107846,21 @@ var ts;
});
}
function containsPrecedingToken(startingToken, sourceFile, container) {
- var precedingToken = ts.Debug.assertDefined(ts.findPrecedingToken(startingToken.getFullStart(), sourceFile, startingToken.parent, /*excludeJsdoc*/ true));
- return ts.rangeContainsRange(container, precedingToken);
+ var pos = startingToken.getFullStart();
+ // There’s a possibility that `startingToken.parent` contains only `startingToken` and
+ // missing nodes, none of which are valid to be returned by `findPrecedingToken`. In that
+ // case, the preceding token we want is actually higher up the tree—almost definitely the
+ // next parent, but theoretically the situation with missing nodes might be happening on
+ // multiple nested levels.
+ var currentParent = startingToken.parent;
+ while (currentParent) {
+ var precedingToken = ts.findPrecedingToken(pos, sourceFile, currentParent, /*excludeJsdoc*/ true);
+ if (precedingToken) {
+ return ts.rangeContainsRange(container, precedingToken);
+ }
+ currentParent = currentParent.parent;
+ }
+ return ts.Debug.fail("Could not find preceding token");
}
function getArgumentInfoForCompletions(node, position, sourceFile) {
var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile);
@@ -108035,7 +108150,7 @@ var ts;
var _loop_7 = function (n) {
// If the node is not a subspan of its parent, this is a big problem.
// There have been crashes that might be caused by this violation.
- ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); });
+ ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); });
var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker);
if (argumentInfo) {
return { value: argumentInfo };
@@ -113101,11 +113216,11 @@ var ts;
function makeChange(changeTracker, sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
if (!ts.isIdentifier(token)) {
- return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.formatSyntaxKind(token.kind));
+ return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.Debug.formatSyntaxKind(token.kind));
}
var param = token.parent;
if (!ts.isParameter(param)) {
- return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.formatSyntaxKind(token.kind));
+ return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.Debug.formatSyntaxKind(token.kind));
}
var i = param.parent.parameters.indexOf(param);
ts.Debug.assert(!param.type, "Tried to add a parameter name to a parameter that already had one.");
@@ -121241,7 +121356,7 @@ var ts;
var textPos = ts.scanner.getTextPos();
if (textPos <= end) {
if (token === 73 /* Identifier */) {
- ts.Debug.fail("Did not expect " + ts.Debug.showSyntaxKind(parent) + " to have an Identifier in its trivia");
+ ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia");
}
nodes.push(createNode(token, pos, textPos, parent));
}
diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js
index fe566943e2c10..59e24f28256a2 100644
--- a/lib/typingsInstaller.js
+++ b/lib/typingsInstaller.js
@@ -76,7 +76,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.5";
/** The version of the TypeScript compiler release */
- ts.version = ts.versionMajorMinor + ".0-rc";
+ ts.version = ts.versionMajorMinor + ".1";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@@ -316,7 +316,7 @@ var ts;
ts.firstDefinedIterator = firstDefinedIterator;
function zipWith(arrayA, arrayB, callback) {
var result = [];
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
for (var i = 0; i < arrayA.length; i++) {
result.push(callback(arrayA[i], arrayB[i], i));
}
@@ -324,7 +324,7 @@ var ts;
}
ts.zipWith = zipWith;
function zipToIterator(arrayA, arrayB) {
- Debug.assertEqual(arrayA.length, arrayB.length);
+ ts.Debug.assertEqual(arrayA.length, arrayB.length);
var i = 0;
return {
next: function () {
@@ -338,7 +338,7 @@ var ts;
}
ts.zipToIterator = zipToIterator;
function zipToMap(keys, values) {
- Debug.assert(keys.length === values.length);
+ ts.Debug.assert(keys.length === values.length);
var map = createMap();
for (var i = 0; i < keys.length; ++i) {
map.set(keys[i], values[i]);
@@ -412,7 +412,7 @@ var ts;
return result;
}
}
- return Debug.fail();
+ return ts.Debug.fail();
}
ts.findMap = findMap;
function contains(array, value, equalityComparer) {
@@ -842,7 +842,7 @@ var ts;
continue;
case -1 /* LessThan */:
// If `array` is sorted, `next` should **never** be less than `last`.
- return Debug.fail("Array is unsorted.");
+ return ts.Debug.fail("Array is unsorted.");
}
deduplicated.push(last = next);
}
@@ -909,13 +909,13 @@ var ts;
loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
if (offsetB > 0) {
// Ensure `arrayB` is properly sorted.
- Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
}
loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
if (offsetA > startA) {
// Ensure `arrayA` is properly sorted. We only need to perform this check if
// `offsetA` has changed since we entered the loop.
- Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
}
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
case -1 /* LessThan */:
@@ -1085,7 +1085,7 @@ var ts;
}
ts.firstOrUndefined = firstOrUndefined;
function first(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[0];
}
ts.first = first;
@@ -1097,7 +1097,7 @@ var ts;
}
ts.lastOrUndefined = lastOrUndefined;
function last(array) {
- Debug.assert(array.length !== 0);
+ ts.Debug.assert(array.length !== 0);
return array[array.length - 1];
}
ts.last = last;
@@ -1422,7 +1422,7 @@ var ts;
function cast(value, test) {
if (value !== undefined && test(value))
return value;
- return Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + Debug.getFunctionName(test) + "'.");
+ return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
}
ts.cast = cast;
/** Does nothing. */
@@ -1491,92 +1491,6 @@ var ts;
AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive";
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
})(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {}));
- var Debug;
- (function (Debug) {
- Debug.currentAssertionLevel = 0 /* None */;
- Debug.isDebugging = false;
- function shouldAssert(level) {
- return Debug.currentAssertionLevel >= level;
- }
- Debug.shouldAssert = shouldAssert;
- function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
- if (!expression) {
- if (verboseDebugInfo) {
- message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
- }
- fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
- }
- }
- Debug.assert = assert;
- function assertEqual(a, b, msg, msg2) {
- if (a !== b) {
- var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
- fail("Expected " + a + " === " + b + ". " + message);
- }
- }
- Debug.assertEqual = assertEqual;
- function assertLessThan(a, b, msg) {
- if (a >= b) {
- fail("Expected " + a + " < " + b + ". " + (msg || ""));
- }
- }
- Debug.assertLessThan = assertLessThan;
- function assertLessThanOrEqual(a, b) {
- if (a > b) {
- fail("Expected " + a + " <= " + b);
- }
- }
- Debug.assertLessThanOrEqual = assertLessThanOrEqual;
- function assertGreaterThanOrEqual(a, b) {
- if (a < b) {
- fail("Expected " + a + " >= " + b);
- }
- }
- Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
- function fail(message, stackCrawlMark) {
- debugger;
- var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
- if (Error.captureStackTrace) {
- Error.captureStackTrace(e, stackCrawlMark || fail);
- }
- throw e;
- }
- Debug.fail = fail;
- function assertDefined(value, message) {
- if (value === undefined || value === null)
- return fail(message);
- return value;
- }
- Debug.assertDefined = assertDefined;
- function assertEachDefined(value, message) {
- for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
- var v = value_1[_i];
- assertDefined(v, message);
- }
- return value;
- }
- Debug.assertEachDefined = assertEachDefined;
- function assertNever(member, message, stackCrawlMark) {
- if (message === void 0) { message = "Illegal value:"; }
- var detail = typeof member === "object" && "kind" in member && "pos" in member ? "SyntaxKind: " + Debug.showSyntaxKind(member) : JSON.stringify(member);
- return fail(message + " " + detail, stackCrawlMark || assertNever);
- }
- Debug.assertNever = assertNever;
- function getFunctionName(func) {
- if (typeof func !== "function") {
- return "";
- }
- else if (func.hasOwnProperty("name")) {
- return func.name;
- }
- else {
- var text = Function.prototype.toString.call(func);
- var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
- return match ? match[1] : "";
- }
- }
- Debug.getFunctionName = getFunctionName;
- })(Debug = ts.Debug || (ts.Debug = {}));
function equateValues(a, b) {
return a === b;
}
@@ -1833,7 +1747,7 @@ var ts;
bestCandidate = candidate;
}
else {
- Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
+ ts.Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
bestDistance = distance;
bestCandidate = candidate;
}
@@ -1977,7 +1891,7 @@ var ts;
* E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar"
*/
function matchedText(pattern, candidate) {
- Debug.assert(isPatternMatch(pattern, candidate));
+ ts.Debug.assert(isPatternMatch(pattern, candidate));
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
}
ts.matchedText = matchedText;
@@ -2096,6 +2010,242 @@ var ts;
}
}
})(ts || (ts = {}));
+/* @internal */
+var ts;
+(function (ts) {
+ var Debug;
+ (function (Debug) {
+ Debug.currentAssertionLevel = 0 /* None */;
+ Debug.isDebugging = false;
+ function shouldAssert(level) {
+ return Debug.currentAssertionLevel >= level;
+ }
+ Debug.shouldAssert = shouldAssert;
+ function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
+ if (!expression) {
+ if (verboseDebugInfo) {
+ message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
+ }
+ fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
+ }
+ }
+ Debug.assert = assert;
+ function assertEqual(a, b, msg, msg2) {
+ if (a !== b) {
+ var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
+ fail("Expected " + a + " === " + b + ". " + message);
+ }
+ }
+ Debug.assertEqual = assertEqual;
+ function assertLessThan(a, b, msg) {
+ if (a >= b) {
+ fail("Expected " + a + " < " + b + ". " + (msg || ""));
+ }
+ }
+ Debug.assertLessThan = assertLessThan;
+ function assertLessThanOrEqual(a, b) {
+ if (a > b) {
+ fail("Expected " + a + " <= " + b);
+ }
+ }
+ Debug.assertLessThanOrEqual = assertLessThanOrEqual;
+ function assertGreaterThanOrEqual(a, b) {
+ if (a < b) {
+ fail("Expected " + a + " >= " + b);
+ }
+ }
+ Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
+ function fail(message, stackCrawlMark) {
+ debugger;
+ var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(e, stackCrawlMark || fail);
+ }
+ throw e;
+ }
+ Debug.fail = fail;
+ function assertDefined(value, message) {
+ if (value === undefined || value === null)
+ return fail(message);
+ return value;
+ }
+ Debug.assertDefined = assertDefined;
+ function assertEachDefined(value, message) {
+ for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
+ var v = value_1[_i];
+ assertDefined(v, message);
+ }
+ return value;
+ }
+ Debug.assertEachDefined = assertEachDefined;
+ function assertNever(member, message, stackCrawlMark) {
+ if (message === void 0) { message = "Illegal value:"; }
+ var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
+ return fail(message + " " + detail, stackCrawlMark || assertNever);
+ }
+ Debug.assertNever = assertNever;
+ function getFunctionName(func) {
+ if (typeof func !== "function") {
+ return "";
+ }
+ else if (func.hasOwnProperty("name")) {
+ return func.name;
+ }
+ else {
+ var text = Function.prototype.toString.call(func);
+ var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
+ return match ? match[1] : "";
+ }
+ }
+ Debug.getFunctionName = getFunctionName;
+ function formatSymbol(symbol) {
+ return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
+ }
+ Debug.formatSymbol = formatSymbol;
+ /**
+ * Formats an enum value as a string for debugging and debug assertions.
+ */
+ function formatEnum(value, enumObject, isFlags) {
+ if (value === void 0) { value = 0; }
+ var members = getEnumMembers(enumObject);
+ if (value === 0) {
+ return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
+ }
+ if (isFlags) {
+ var result = "";
+ var remainingFlags = value;
+ for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
+ var _a = members[i], enumValue = _a[0], enumName = _a[1];
+ if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
+ remainingFlags &= ~enumValue;
+ result = "" + enumName + (result ? "|" : "") + result;
+ }
+ }
+ if (remainingFlags === 0) {
+ return result;
+ }
+ }
+ else {
+ for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
+ var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
+ if (enumValue === value) {
+ return enumName;
+ }
+ }
+ }
+ return value.toString();
+ }
+ Debug.formatEnum = formatEnum;
+ function getEnumMembers(enumObject) {
+ var result = [];
+ for (var name in enumObject) {
+ var value = enumObject[name];
+ if (typeof value === "number") {
+ result.push([value, name]);
+ }
+ }
+ return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
+ }
+ function formatSyntaxKind(kind) {
+ return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
+ }
+ Debug.formatSyntaxKind = formatSyntaxKind;
+ function formatNodeFlags(flags) {
+ return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
+ }
+ Debug.formatNodeFlags = formatNodeFlags;
+ function formatModifierFlags(flags) {
+ return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
+ }
+ Debug.formatModifierFlags = formatModifierFlags;
+ function formatTransformFlags(flags) {
+ return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
+ }
+ Debug.formatTransformFlags = formatTransformFlags;
+ function formatEmitFlags(flags) {
+ return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
+ }
+ Debug.formatEmitFlags = formatEmitFlags;
+ function formatSymbolFlags(flags) {
+ return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
+ }
+ Debug.formatSymbolFlags = formatSymbolFlags;
+ function formatTypeFlags(flags) {
+ return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
+ }
+ Debug.formatTypeFlags = formatTypeFlags;
+ function formatObjectFlags(flags) {
+ return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
+ }
+ Debug.formatObjectFlags = formatObjectFlags;
+ function failBadSyntaxKind(node, message) {
+ return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
+ }
+ Debug.failBadSyntaxKind = failBadSyntaxKind;
+ Debug.assertEachNode = shouldAssert(1 /* Normal */)
+ ? function (nodes, test, message) { return assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertEachNode); }
+ : ts.noop;
+ Debug.assertNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); }
+ : ts.noop;
+ Debug.assertOptionalNode = shouldAssert(1 /* Normal */)
+ ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
+ : ts.noop;
+ Debug.assertOptionalToken = shouldAssert(1 /* Normal */)
+ ? function (node, kind, message) { return assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
+ : ts.noop;
+ Debug.assertMissingNode = shouldAssert(1 /* Normal */)
+ ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
+ : ts.noop;
+ var isDebugInfoEnabled = false;
+ /**
+ * Injects debug information into frequently used types.
+ */
+ function enableDebugInfo() {
+ if (isDebugInfoEnabled)
+ return;
+ // Add additional properties in debug mode to assist with debugging.
+ Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
+ __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
+ });
+ Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
+ __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
+ __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } },
+ __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
+ });
+ var nodeConstructors = [
+ ts.objectAllocator.getNodeConstructor(),
+ ts.objectAllocator.getIdentifierConstructor(),
+ ts.objectAllocator.getTokenConstructor(),
+ ts.objectAllocator.getSourceFileConstructor()
+ ];
+ for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
+ var ctor = nodeConstructors_1[_i];
+ if (!ctor.prototype.hasOwnProperty("__debugKind")) {
+ Object.defineProperties(ctor.prototype, {
+ __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
+ __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
+ __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
+ __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
+ __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
+ __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
+ __debugGetText: {
+ value: function (includeTrivia) {
+ if (ts.nodeIsSynthesized(this))
+ return "";
+ var parseNode = ts.getParseTreeNode(this);
+ var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
+ return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
+ }
+ }
+ });
+ }
+ }
+ isDebugInfoEnabled = true;
+ }
+ Debug.enableDebugInfo = enableDebugInfo;
+ })(Debug = ts.Debug || (ts.Debug = {}));
+})(ts || (ts = {}));
/*@internal*/
var ts;
(function (ts) {
@@ -5324,7 +5474,7 @@ var ts;
Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."),
Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
- Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", "Cannot compile namespaces when the '--isolatedModules' flag is provided."),
+ All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."),
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."),
A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
@@ -6111,7 +6261,6 @@ var ts;
Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."),
Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
Multiple_consecutive_numeric_separators_are_not_permitted: diag(6189, ts.DiagnosticCategory.Error, "Multiple_consecutive_numeric_separators_are_not_permitted_6189", "Multiple consecutive numeric separators are not permitted."),
- Found_package_json_at_0_Package_ID_is_1: diag(6190, ts.DiagnosticCategory.Message, "Found_package_json_at_0_Package_ID_is_1_6190", "Found 'package.json' at '{0}'. Package ID is '{1}'."),
Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: diag(6191, ts.DiagnosticCategory.Message, "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191", "Whether to keep outdated console output in watch mode instead of clearing the screen."),
All_imports_in_import_declaration_are_unused: diag(6192, ts.DiagnosticCategory.Error, "All_imports_in_import_declaration_are_unused_6192", "All imports in import declaration are unused.", /*reportsUnnecessary*/ true),
Found_1_error_Watching_for_file_changes: diag(6193, ts.DiagnosticCategory.Message, "Found_1_error_Watching_for_file_changes_6193", "Found 1 error. Watching for file changes."),
@@ -6138,6 +6287,9 @@ var ts;
Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."),
Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
+ Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"),
+ Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"),
+ package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."),
Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
@@ -6227,6 +6379,8 @@ var ts;
_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."),
Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1: diag(7051, ts.DiagnosticCategory.Error, "Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1_7051", "Parameter has a name but no type. Did you mean '{0}: {1}'?"),
Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1: diag(7052, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1_7052", "Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}' ?"),
+ Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: diag(7053, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053", "Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'."),
+ No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1: diag(7054, ts.DiagnosticCategory.Error, "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054", "No index signature with a parameter of type '{0}' was found on type '{1}'."),
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."),
@@ -10300,7 +10454,7 @@ var ts;
}
ts.isFunctionSymbol = isFunctionSymbol;
function importFromModuleSpecifier(node) {
- return tryGetImportFromModuleSpecifier(node) || ts.Debug.fail(ts.Debug.showSyntaxKind(node.parent));
+ return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
}
ts.importFromModuleSpecifier = importFromModuleSpecifier;
function tryGetImportFromModuleSpecifier(node) {
@@ -12255,77 +12409,6 @@ var ts;
return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
}
ts.getNewLineCharacter = getNewLineCharacter;
- /**
- * Formats an enum value as a string for debugging and debug assertions.
- */
- function formatEnum(value, enumObject, isFlags) {
- if (value === void 0) { value = 0; }
- var members = getEnumMembers(enumObject);
- if (value === 0) {
- return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
- }
- if (isFlags) {
- var result = "";
- var remainingFlags = value;
- for (var i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) {
- var _a = members[i], enumValue = _a[0], enumName = _a[1];
- if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) {
- remainingFlags &= ~enumValue;
- result = "" + enumName + (result ? ", " : "") + result;
- }
- }
- if (remainingFlags === 0) {
- return result;
- }
- }
- else {
- for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
- var _b = members_1[_i], enumValue = _b[0], enumName = _b[1];
- if (enumValue === value) {
- return enumName;
- }
- }
- }
- return value.toString();
- }
- function getEnumMembers(enumObject) {
- var result = [];
- for (var name in enumObject) {
- var value = enumObject[name];
- if (typeof value === "number") {
- result.push([value, name]);
- }
- }
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
- }
- function formatSyntaxKind(kind) {
- return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
- }
- ts.formatSyntaxKind = formatSyntaxKind;
- function formatModifierFlags(flags) {
- return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true);
- }
- ts.formatModifierFlags = formatModifierFlags;
- function formatTransformFlags(flags) {
- return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true);
- }
- ts.formatTransformFlags = formatTransformFlags;
- function formatEmitFlags(flags) {
- return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true);
- }
- ts.formatEmitFlags = formatEmitFlags;
- function formatSymbolFlags(flags) {
- return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true);
- }
- ts.formatSymbolFlags = formatSymbolFlags;
- function formatTypeFlags(flags) {
- return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true);
- }
- ts.formatTypeFlags = formatTypeFlags;
- function formatObjectFlags(flags) {
- return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true);
- }
- ts.formatObjectFlags = formatObjectFlags;
/**
* Creates a new TextRange from the provided pos and end.
*
@@ -15519,6 +15602,15 @@ var ts;
return root + pathComponents.slice(1).join(ts.directorySeparator);
}
ts.getPathFromPathComponents = getPathFromPathComponents;
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
+ }
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
+ function getPathWithoutRoot(pathComponents) {
+ if (pathComponents.length === 0)
+ return "";
+ return pathComponents.slice(1).join(ts.directorySeparator);
+ }
})(ts || (ts = {}));
/* @internal */
(function (ts) {
@@ -15549,7 +15641,7 @@ var ts;
}
ts.getRelativePathFromFile = getRelativePathFromFile;
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
- Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
+ ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
@@ -16193,32 +16285,9 @@ var ts;
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
}
ts.changeAnyExtension = changeAnyExtension;
- var Debug;
- (function (Debug) {
- function showSymbol(symbol) {
- var symbolFlags = ts.SymbolFlags;
- return "{ flags: " + (symbolFlags ? showFlags(symbol.flags, symbolFlags) : symbol.flags) + "; declarations: " + ts.map(symbol.declarations, showSyntaxKind) + " }";
- }
- Debug.showSymbol = showSymbol;
- function showFlags(flags, flagsEnum) {
- var out = [];
- for (var pow = 0; pow <= 30; pow++) {
- var n = 1 << pow;
- if (flags & n) {
- out.push(flagsEnum[n]);
- }
- }
- return out.join("|");
- }
- function showSyntaxKind(node) {
- var syntaxKind = ts.SyntaxKind;
- return syntaxKind ? syntaxKind[node.kind] : node.kind.toString();
- }
- Debug.showSyntaxKind = showSyntaxKind;
- })(Debug = ts.Debug || (ts.Debug = {}));
function tryParsePattern(pattern) {
// This should be verified outside of here and a proper error thrown.
- Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
+ ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern));
var indexOfStar = pattern.indexOf("*");
return indexOfStar === -1 ? undefined : {
prefix: pattern.substr(0, indexOfStar),
@@ -16247,7 +16316,7 @@ var ts;
*/
function extensionFromPath(path) {
var ext = tryGetExtensionFromPath(path);
- return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension.");
+ return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
}
ts.extensionFromPath = extensionFromPath;
function isAnySupportedFileExtension(path) {
@@ -16319,7 +16388,7 @@ var ts;
ts.matchPatternOrExact = matchPatternOrExact;
function sliceAfter(arr, value) {
var index = arr.indexOf(value);
- Debug.assert(index !== -1);
+ ts.Debug.assert(index !== -1);
return arr.slice(index);
}
ts.sliceAfter = sliceAfter;
@@ -16337,7 +16406,7 @@ var ts;
}
ts.addRelatedInfo = addRelatedInfo;
function minAndMax(arr, getValue) {
- Debug.assert(arr.length !== 0);
+ ts.Debug.assert(arr.length !== 0);
var min = getValue(arr[0]);
var max = min;
for (var i = 1; i < arr.length; i++) {
@@ -25733,7 +25802,7 @@ var ts;
if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) {
extendedConfigPath = extendedConfigPath + ".json";
if (!host.fileExists(extendedConfigPath)) {
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
}
@@ -25744,7 +25813,7 @@ var ts;
if (resolved.resolvedModule) {
return resolved.resolvedModule.resolvedFileName;
}
- errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig));
+ errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
return undefined;
}
function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
@@ -26259,11 +26328,22 @@ var ts;
return !!compilerOptions.traceResolution && host.trace !== undefined;
}
ts.isTraceEnabled = isTraceEnabled;
- function withPackageId(packageId, r) {
+ function withPackageId(packageInfo, r) {
+ var packageId;
+ if (r && packageInfo) {
+ var packageJsonContent = packageInfo.packageJsonContent;
+ if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
+ packageId = {
+ name: packageJsonContent.name,
+ subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
+ version: packageJsonContent.version
+ };
+ }
+ }
return r && { path: r.path, extension: r.ext, packageId: packageId };
}
function noPackageId(r) {
- return withPackageId(/*packageId*/ undefined, r);
+ return withPackageId(/*packageInfo*/ undefined, r);
}
function removeIgnoredPackageId(r) {
if (r) {
@@ -26315,8 +26395,15 @@ var ts;
}
function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
- if (fileName === undefined)
+ if (fileName === undefined) {
return;
+ }
+ if (!fileName) {
+ if (state.traceEnabled) {
+ trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
+ }
+ return;
+ }
var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
@@ -26469,7 +26556,12 @@ var ts;
var fileName = resolved.fileName, packageId = resolved.packageId;
var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
if (traceEnabled) {
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ if (packageId) {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary);
+ }
+ else {
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
+ }
}
resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
}
@@ -26757,7 +26849,12 @@ var ts;
}
if (traceEnabled) {
if (result.resolvedModule) {
- trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ if (result.resolvedModule.packageId) {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2, moduleName, result.resolvedModule.resolvedFileName, ts.packageIdToString(result.resolvedModule.packageId));
+ }
+ else {
+ trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
+ }
}
else {
trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
@@ -27027,10 +27124,9 @@ var ts;
}
var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
if (resolvedFromFile) {
- var nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
- var packageInfo = nm && getPackageJsonInfo(nm.packageDirectory, nm.subModuleName, /*onlyRecordFailures*/ false, state);
- var packageId = packageInfo && packageInfo.packageId;
- return withPackageId(packageId, resolvedFromFile);
+ var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
+ var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined;
+ return withPackageId(packageInfo, resolvedFromFile);
}
}
if (!onlyRecordFailures) {
@@ -27056,11 +27152,10 @@ var ts;
* (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.)
*
* packageDirectory is the directory of the package itself.
- * subModuleName is the path within the package.
- * For `blah/node_modules/foo/index.d.ts` this is { packageDirectory: "foo", subModuleName: "index.d.ts" }. (Part before "/node_modules/" is ignored.)
- * For `/node_modules/foo/bar.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
- * For `/node_modules/@types/foo/bar/index.d.ts` this is { packageDirectory: "@types/foo", subModuleName: "bar/index.d.ts" }.
- * For `/node_modules/foo/bar/index.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }.
+ * For `blah/node_modules/foo/index.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/foo/bar.d.ts` this is packageDirectory: "foo"
+ * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo"
+ * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo"
*/
function parseNodeModuleFromPath(resolved) {
var path = ts.normalizePath(resolved.path);
@@ -27073,26 +27168,12 @@ var ts;
if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) {
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
}
- var packageDirectory = path.slice(0, indexAfterPackageName);
- var subModuleName = ts.removeExtension(path.slice(indexAfterPackageName + 1), resolved.ext) + ".d.ts" /* Dts */;
- return { packageDirectory: packageDirectory, subModuleName: subModuleName };
+ return path.slice(0, indexAfterPackageName);
}
function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
}
- function addExtensionAndIndex(path) {
- if (path === "") {
- return "index.d.ts";
- }
- if (ts.endsWith(path, ".d.ts")) {
- return path;
- }
- if (path === "index" || ts.endsWith(path, "/index")) {
- return path + ".d.ts";
- }
- return path + "/index.d.ts";
- }
function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
}
@@ -27166,52 +27247,22 @@ var ts;
}
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
if (considerPackageJson === void 0) { considerPackageJson = true; }
- var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, "", onlyRecordFailures, state) : undefined;
- var packageId = packageInfo && packageInfo.packageId;
+ var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
var versionPaths = packageInfo && packageInfo.versionPaths;
- return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
+ return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
}
- function getPackageJsonInfo(packageDirectory, subModuleName, onlyRecordFailures, state) {
+ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
var host = state.host, traceEnabled = state.traceEnabled;
var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
if (directoryExists && host.fileExists(packageJsonPath)) {
var packageJsonContent = ts.readJson(packageJsonPath, host);
- if (subModuleName === "") { // looking up the root - need to handle types/typings/main redirects for subModuleName
- var path = readPackageJsonTypesFields(packageJsonContent, packageDirectory, state);
- if (typeof path === "string") {
- subModuleName = addExtensionAndIndex(path.substring(packageDirectory.length + 1));
- }
- else {
- var jsPath = readPackageJsonMainField(packageJsonContent, packageDirectory, state);
- if (typeof jsPath === "string" && jsPath.length > packageDirectory.length) {
- var potentialSubModule_1 = jsPath.substring(packageDirectory.length + 1);
- subModuleName = (ts.forEach(ts.supportedJSExtensions, function (extension) {
- return ts.tryRemoveExtension(potentialSubModule_1, extension);
- }) || potentialSubModule_1) + ".d.ts" /* Dts */;
- }
- else {
- subModuleName = "index.d.ts";
- }
- }
- }
- if (!ts.endsWith(subModuleName, ".d.ts" /* Dts */)) {
- subModuleName = addExtensionAndIndex(subModuleName);
- }
- var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
- var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string"
- ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version }
- : undefined;
if (traceEnabled) {
- if (packageId) {
- trace(host, ts.Diagnostics.Found_package_json_at_0_Package_ID_is_1, packageJsonPath, ts.packageIdToString(packageId));
- }
- else {
- trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
- }
+ trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
}
- return { packageJsonContent: packageJsonContent, packageId: packageId, versionPaths: versionPaths };
+ var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
+ return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
}
else {
if (directoryExists && traceEnabled) {
@@ -27350,37 +27401,31 @@ var ts;
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
- var packageJsonContent;
- var packageId;
- var versionPaths;
- var packageInfo = getPackageJsonInfo(candidate, "", !nodeModulesDirectoryExists, state);
+ var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
if (packageInfo) {
- (packageJsonContent = packageInfo.packageJsonContent, packageId = packageInfo.packageId, versionPaths = packageInfo.versionPaths);
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
if (fromFile) {
return noPackageId(fromFile);
}
- var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, fromDirectory);
+ var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
+ return withPackageId(packageInfo, fromDirectory);
}
var loader = function (extensions, candidate, onlyRecordFailures, state) {
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
- loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths);
- return withPackageId(packageId, pathAndExtension);
+ loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
+ return withPackageId(packageInfo, pathAndExtension);
};
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
if (rest !== "") { // If "rest" is empty, we just did this search above.
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
// Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings.
- var packageInfo_1 = getPackageJsonInfo(packageDirectory, rest, !nodeModulesDirectoryExists, state);
- if (packageInfo_1)
- (packageId = packageInfo_1.packageId, versionPaths = packageInfo_1.versionPaths);
- if (versionPaths) {
+ packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
+ if (packageInfo && packageInfo.versionPaths) {
if (state.traceEnabled) {
- trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, rest);
+ trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest);
}
var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, versionPaths.paths, loader, !packageDirectoryExists, state);
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
if (fromPaths) {
return fromPaths.value;
}
@@ -29835,7 +29880,7 @@ var ts;
}
break;
default:
- ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer));
+ ts.Debug.failBadSyntaxKind(thisContainer);
}
}
function bindSpecialPropertyDeclaration(node) {
@@ -29893,7 +29938,7 @@ var ts;
// Fix up parent pointers since we're going to use these nodes before we bind into them
node.left.parent = node;
node.right.parent = node;
- if (ts.isIdentifier(lhs.expression) && container === file && isNameOfExportsOrModuleExportsAliasDeclaration(file, lhs.expression)) {
+ if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) {
// This can be an alias for the 'exports' or 'module.exports' names, e.g.
// var util = module.exports;
// util.property = function ...
@@ -30248,20 +30293,29 @@ var ts;
}
}
function isExportsOrModuleExportsOrAlias(sourceFile, node) {
- return ts.isExportsIdentifier(node) ||
- ts.isModuleExportsPropertyAccessExpression(node) ||
- ts.isIdentifier(node) && isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node);
+ var i = 0;
+ var q = [node];
+ while (q.length && i < 100) {
+ i++;
+ node = q.shift();
+ if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) {
+ return true;
+ }
+ else if (ts.isIdentifier(node)) {
+ var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
+ if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
+ var init = symbol.valueDeclaration.initializer;
+ q.push(init);
+ if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) {
+ q.push(init.left);
+ q.push(init.right);
+ }
+ }
+ }
+ }
+ return false;
}
ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
- function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) {
- var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
- return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) &&
- !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer);
- }
- function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) {
- return isExportsOrModuleExportsOrAlias(sourceFile, node) ||
- (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && (isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.left) || isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.right)));
- }
function lookupSymbolForNameWorker(container, name) {
var local = container.locals && container.locals.get(name);
if (local) {
@@ -31401,6 +31455,10 @@ var ts;
node = ts.getParseTreeNode(node);
return node ? getTypeOfNode(node) : errorType;
},
+ getTypeOfAssignmentPattern: function (nodeIn) {
+ var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
+ return node && getTypeOfAssignmentPattern(node) || errorType;
+ },
getPropertySymbolOfDestructuringAssignment: function (locationIn) {
var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
@@ -34501,7 +34559,7 @@ var ts;
context.approximateLength += 6;
return ts.createKeywordTypeNode(137 /* ObjectKeyword */);
}
- if (type.flags & 262144 /* TypeParameter */ && type.isThisType) {
+ if (isThisTypeParameter(type)) {
if (context.flags & 4194304 /* InObjectTypeLiteral */) {
if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
context.encounteredError = true;
@@ -35191,6 +35249,11 @@ var ts;
function lookupTypeParameterNodes(chain, index, context) {
ts.Debug.assert(chain && 0 <= index && index < chain.length);
var symbol = chain[index];
+ var symbolId = "" + getSymbolId(symbol);
+ if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
+ return undefined;
+ }
+ (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
var typeParameterNodes;
if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) {
var parentSymbol = symbol;
@@ -36131,7 +36194,7 @@ var ts;
return type;
}
else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(declaredType, declaration, type);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
}
}
return declaredType;
@@ -36450,7 +36513,7 @@ var ts;
type = getTypeOfEnumMember(symbol);
}
else {
- return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol));
+ return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
}
if (!popTypeResolution()) {
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
@@ -37720,10 +37783,10 @@ var ts;
// Union the result types when more than one signature matches
if (unionSignatures.length > 1) {
var thisParameter = signature.thisParameter;
- if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) {
- // TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do
+ var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
+ if (firstThisParameterOfUnionSignatures) {
var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */);
- thisParameter = createSymbolWithType(signature.thisParameter, thisType);
+ thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
}
s = createUnionSignature(signature, unionSignatures);
s.thisParameter = thisParameter;
@@ -38289,15 +38352,19 @@ var ts;
function getConstraintOfIndexedAccess(type) {
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
}
+ function getSimplifiedTypeOrConstraint(type) {
+ var simplified = getSimplifiedType(type, /*writing*/ false);
+ return simplified !== type ? simplified : getConstraintOfType(type);
+ }
function getConstraintFromIndexedAccess(type) {
- var indexConstraint = getConstraintOfType(type.indexType);
+ var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
if (indexConstraint && indexConstraint !== type.indexType) {
var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
if (indexedAccess) {
return indexedAccess;
}
}
- var objectConstraint = getConstraintOfType(type.objectType);
+ var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
if (objectConstraint && objectConstraint !== type.objectType) {
return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
}
@@ -40286,6 +40353,14 @@ var ts;
types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
return true;
}
+ function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
+ var result = createType(2097152 /* Intersection */);
+ result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
+ result.types = types;
+ result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
+ result.aliasTypeArguments = aliasTypeArguments;
+ return result;
+ }
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
@@ -40323,30 +40398,36 @@ var ts;
if (typeSet.length === 1) {
return typeSet[0];
}
- if (includes & 1048576 /* Union */) {
- if (intersectUnionsOfPrimitiveTypes(typeSet)) {
- // When the intersection creates a reduced set (which might mean that *all* union types have
- // disappeared), we restart the operation to get a new set of combined flags. Once we have
- // reduced we'll never reduce again, so this occurs at most once.
- return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
- }
- // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
- // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
- var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
- var unionType = typeSet[unionIndex_1];
- return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
- }
var id = getTypeListId(typeSet);
- var type = intersectionTypes.get(id);
- if (!type) {
- type = createType(2097152 /* Intersection */);
- intersectionTypes.set(id, type);
- type.objectFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */);
- type.types = typeSet;
- type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`.
- type.aliasTypeArguments = aliasTypeArguments;
+ var result = intersectionTypes.get(id);
+ if (!result) {
+ if (includes & 1048576 /* Union */) {
+ if (intersectUnionsOfPrimitiveTypes(typeSet)) {
+ // When the intersection creates a reduced set (which might mean that *all* union types have
+ // disappeared), we restart the operation to get a new set of combined flags. Once we have
+ // reduced we'll never reduce again, so this occurs at most once.
+ result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ else {
+ // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
+ // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
+ // If the estimated size of the resulting union type exceeds 100000 constituents, report an error.
+ var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 /* Union */ ? t.types.length : 1); }, 1);
+ if (size >= 100000) {
+ error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
+ return errorType;
+ }
+ var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; });
+ var unionType = typeSet[unionIndex_1];
+ result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments);
+ }
+ }
+ else {
+ result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
+ intersectionTypes.set(id, result);
}
- return type;
+ return result;
}
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
@@ -40479,7 +40560,7 @@ var ts;
}
return false;
}
- function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, accessNode, accessFlags) {
+ function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined;
var propName = isTypeUsableAsPropertyName(indexType) ?
getPropertyNameFromType(indexType) :
@@ -40517,6 +40598,7 @@ var ts;
error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
}
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */));
return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
}
}
@@ -40538,13 +40620,7 @@ var ts;
error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
return indexInfo.type;
}
- if (indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
- if (accessExpression) {
- error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
- return indexInfo.type;
- }
- return undefined;
- }
+ errorIfWritingToReadonlyIndex(indexInfo);
return indexInfo.type;
}
if (indexType.flags & 131072 /* Never */) {
@@ -40557,7 +40633,7 @@ var ts;
if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) {
error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
- else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
+ else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
}
@@ -40577,7 +40653,25 @@ var ts;
error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion_1);
}
else {
- error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType));
+ var errorInfo = void 0;
+ if (indexType.flags & 1024 /* EnumLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 8192 /* UniqueESSymbol */) {
+ var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
+ }
+ else if (indexType.flags & 128 /* StringLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & 256 /* NumberLiteral */) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
+ }
+ else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
+ errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
+ }
+ errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType));
+ diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
}
}
}
@@ -40604,6 +40698,11 @@ var ts;
return indexType;
}
return undefined;
+ function errorIfWritingToReadonlyIndex(indexInfo) {
+ if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
+ error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
+ }
+ }
}
function getIndexNodeForAccessExpression(accessNode) {
return accessNode.kind === 191 /* ElementAccessExpression */
@@ -40620,6 +40719,9 @@ var ts;
function isGenericIndexType(type) {
return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */);
}
+ function isThisTypeParameter(type) {
+ return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
+ }
function getSimplifiedType(type, writing) {
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
@@ -40755,7 +40857,7 @@ var ts;
var wasMissingProp = false;
for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
var t = _a[_i];
- var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, accessNode, accessFlags);
+ var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
if (propType) {
propTypes.push(propType);
}
@@ -40773,7 +40875,7 @@ var ts;
}
return accessFlags & 2 /* Writing */ ? getIntersectionType(propTypes) : getUnionType(propTypes);
}
- return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, accessNode, accessFlags | 4 /* CacheSymbol */);
+ return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */);
}
function getTypeFromIndexedAccessTypeNode(node) {
var links = getNodeLinks(node);
@@ -43319,8 +43421,7 @@ var ts;
}
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
// simplified form of T or, if T doesn't simplify, the constraint of T.
- var simplified = getSimplifiedType(target.type, /*writing*/ false);
- var constraint = simplified !== target.type ? simplified : getConstraintOfType(target.type);
+ var constraint = getSimplifiedTypeOrConstraint(target.type);
if (constraint) {
// We require Ternary.True here such that circular constraints don't cause
// false positives. For example, given 'T extends { [K in keyof T]: string }',
@@ -46861,7 +46962,7 @@ var ts;
return !assumeTrue;
}
function narrowByInKeyword(type, literal, assumeTrue) {
- if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) {
+ if (type.flags & (1048576 /* Union */ | 524288 /* Object */) || isThisTypeParameter(type)) {
var propName_1 = ts.escapeLeadingUnderscores(literal.text);
return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
}
@@ -48413,8 +48514,8 @@ var ts;
// For a (non-symbol) computed property, there is no reason to look up the name
// in the type. It will just be "__computed", which does not appear in any
// SymbolTable.
- var symbolName_2 = getSymbolOfNode(element).escapedName;
- var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_2);
+ var symbolName_3 = getSymbolOfNode(element).escapedName;
+ var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
if (propertyType) {
return propertyType;
}
@@ -49889,7 +49990,7 @@ var ts;
return anyType;
}
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
- reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType);
+ reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
}
return errorType;
}
@@ -50254,7 +50355,7 @@ var ts;
}
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
var accessFlags = ts.isAssignmentTarget(node) ?
- 2 /* Writing */ | (isGenericObjectType(objectType) ? 1 /* NoIndexSignatures */ : 0) :
+ 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) :
0 /* None */;
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
return checkIndexedAccessIndexType(indexedAccessType, node);
@@ -52834,15 +52935,16 @@ var ts;
if (strictNullChecks && properties.length === 0) {
return checkNonNullType(sourceType, node);
}
- for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
- var p = properties_4[_i];
- checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis);
+ for (var i = 0; i < properties.length; i++) {
+ checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
}
return sourceType;
}
/** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */
- function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) {
+ function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
if (rightIsThis === void 0) { rightIsThis = false; }
+ var properties = node.properties;
+ var property = properties[propertyIndex];
if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) {
var name = property.name;
var exprType = getLiteralTypeFromPropertyName(name);
@@ -52859,18 +52961,26 @@ var ts;
return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
}
else if (property.kind === 278 /* SpreadAssignment */) {
- if (languageVersion < 8 /* ESNext */) {
- checkExternalEmitHelpers(property, 4 /* Rest */);
+ if (propertyIndex < properties.length - 1) {
+ error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
}
- var nonRestNames = [];
- if (allProperties) {
- for (var i = 0; i < allProperties.length - 1; i++) {
- nonRestNames.push(allProperties[i].name);
+ else {
+ if (languageVersion < 8 /* ESNext */) {
+ checkExternalEmitHelpers(property, 4 /* Rest */);
+ }
+ var nonRestNames = [];
+ if (allProperties) {
+ for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
+ var otherProperty = allProperties_1[_i];
+ if (!ts.isSpreadAssignment(otherProperty)) {
+ nonRestNames.push(otherProperty.name);
+ }
+ }
}
+ var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
+ checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
+ return checkDestructuringAssignment(property.expression, type);
}
- var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
- checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
- return checkDestructuringAssignment(property.expression, type);
}
else {
error(property, ts.Diagnostics.Property_assignment_expected);
@@ -54809,7 +54919,7 @@ var ts;
case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591
return 1 /* ExportValue */;
default:
- return ts.Debug.fail(ts.Debug.showSyntaxKind(d));
+ return ts.Debug.failBadSyntaxKind(d);
}
}
}
@@ -55974,7 +56084,7 @@ var ts;
if (type !== errorType && declarationType !== errorType &&
!isTypeIdenticalTo(type, declarationType) &&
!(symbol.flags & 67108864 /* Assignment */)) {
- errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType);
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
}
if (node.initializer) {
checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined);
@@ -55993,12 +56103,16 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) {
+ function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */
? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
: ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
- error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType));
+ var declName = ts.declarationNameToString(nextDeclarationName);
+ var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
+ if (firstDeclaration) {
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
+ }
}
function areDeclarationFlagsIdentical(left, right) {
if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) ||
@@ -57139,8 +57253,8 @@ var ts;
for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
var base = baseTypes_2[_i];
var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
- for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) {
- var prop = properties_5[_a];
+ for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) {
+ var prop = properties_4[_a];
var existing = seen.get(prop.escapedName);
if (!existing) {
seen.set(prop.escapedName, { prop: prop, containingType: base });
@@ -58756,7 +58870,7 @@ var ts;
// }
// [ a ] from
// [a] = [ some array ...]
- function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) {
+ function getTypeOfAssignmentPattern(expr) {
ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */);
// If this is from "for of"
// for ( { a } of elems) {
@@ -58774,15 +58888,17 @@ var ts;
// If this is from nested object binding pattern
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
if (expr.parent.kind === 276 /* PropertyAssignment */) {
- var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent);
- return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217
+ var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
+ var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType;
+ var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent);
+ return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex);
}
// Array literal assignment - array destructuring pattern
- ts.Debug.assert(expr.parent.kind === 188 /* ArrayLiteralExpression */);
+ var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
// [{ property1: p1, property2 }] = elems;
- var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent);
- var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
- return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); // TODO: GH#18217
+ var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
+ var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType;
+ return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
}
// Gets the property symbol corresponding to the property in destructuring assignment
// 'property1' from
@@ -58792,7 +58908,7 @@ var ts;
// [a] = [ property1, property2 ]
function getPropertySymbolOfDestructuringAssignment(location) {
// Get the type of the object or array literal and then look for property of given name in the type
- var typeOfObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(location.parent.parent);
+ var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
}
function getRegularTypeOfExpression(expr) {
@@ -58958,12 +59074,16 @@ var ts;
}
return undefined;
}
+ function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
+ return ts.isBindingElement(symbol.valueDeclaration)
+ && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */;
+ }
function isSymbolOfDeclarationWithCollidingName(symbol) {
if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) {
var links = getSymbolLinks(symbol);
if (links.isDeclarationWithCollidingName === undefined) {
var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
- if (ts.isStatementWithLocals(container)) {
+ if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) {
// redeclaration - always should be renamed
@@ -64446,7 +64566,7 @@ var ts;
function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
if (property === firstAccessor) {
- var properties_6 = [];
+ var properties_5 = [];
if (getAccessor) {
var getterFunction = ts.createFunctionExpression(getAccessor.modifiers,
/*asteriskToken*/ undefined,
@@ -64457,7 +64577,7 @@ var ts;
ts.setTextRange(getterFunction, getAccessor);
ts.setOriginalNode(getterFunction, getAccessor);
var getter = ts.createPropertyAssignment("get", getterFunction);
- properties_6.push(getter);
+ properties_5.push(getter);
}
if (setAccessor) {
var setterFunction = ts.createFunctionExpression(setAccessor.modifiers,
@@ -64469,15 +64589,15 @@ var ts;
ts.setTextRange(setterFunction, setAccessor);
ts.setOriginalNode(setterFunction, setAccessor);
var setter = ts.createPropertyAssignment("set", setterFunction);
- properties_6.push(setter);
+ properties_5.push(setter);
}
- properties_6.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
- properties_6.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("enumerable", ts.createTrue()));
+ properties_5.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"),
/*typeArguments*/ undefined, [
receiver,
createExpressionForPropertyName(property.name),
- ts.createObjectLiteral(properties_6, multiLine)
+ ts.createObjectLiteral(properties_5, multiLine)
]),
/*location*/ firstAccessor);
return ts.aggregateTransformFlags(expression);
@@ -66456,7 +66576,7 @@ var ts;
* @param nodes The NodeArray.
*/
function liftToBlock(nodes) {
- Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
+ ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
}
ts.liftToBlock = liftToBlock;
@@ -66521,73 +66641,6 @@ var ts;
function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
}
- var Debug;
- (function (Debug) {
- var isDebugInfoEnabled = false;
- function failBadSyntaxKind(node, message) {
- return Debug.fail((message || "Unexpected node.") + "\r\nNode " + ts.formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind);
- }
- Debug.failBadSyntaxKind = failBadSyntaxKind;
- Debug.assertEachNode = Debug.shouldAssert(1 /* Normal */)
- ? function (nodes, test, message) { return Debug.assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertEachNode); }
- : ts.noop;
- Debug.assertNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertNode); }
- : ts.noop;
- Debug.assertOptionalNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, test, message) { return Debug.assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + Debug.getFunctionName(test) + "'."; }, Debug.assertOptionalNode); }
- : ts.noop;
- Debug.assertOptionalToken = Debug.shouldAssert(1 /* Normal */)
- ? function (node, kind, message) { return Debug.assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was not a '" + ts.formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); }
- : ts.noop;
- Debug.assertMissingNode = Debug.shouldAssert(1 /* Normal */)
- ? function (node, message) { return Debug.assert(node === undefined, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); }
- : ts.noop;
- /**
- * Injects debug information into frequently used types.
- */
- function enableDebugInfo() {
- if (isDebugInfoEnabled)
- return;
- // Add additional properties in debug mode to assist with debugging.
- Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatSymbolFlags(this.flags); } }
- });
- Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
- __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } },
- __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } },
- __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
- });
- var nodeConstructors = [
- ts.objectAllocator.getNodeConstructor(),
- ts.objectAllocator.getIdentifierConstructor(),
- ts.objectAllocator.getTokenConstructor(),
- ts.objectAllocator.getSourceFileConstructor()
- ];
- for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
- var ctor = nodeConstructors_1[_i];
- if (!ctor.prototype.hasOwnProperty("__debugKind")) {
- Object.defineProperties(ctor.prototype, {
- __debugKind: { get: function () { return ts.formatSyntaxKind(this.kind); } },
- __debugModifierFlags: { get: function () { return ts.formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
- __debugTransformFlags: { get: function () { return ts.formatTransformFlags(this.transformFlags); } },
- __debugEmitFlags: { get: function () { return ts.formatEmitFlags(ts.getEmitFlags(this)); } },
- __debugGetText: {
- value: function (includeTrivia) {
- if (ts.nodeIsSynthesized(this))
- return "";
- var parseNode = ts.getParseTreeNode(this);
- var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
- return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
- }
- }
- });
- }
- }
- isDebugInfoEnabled = true;
- }
- Debug.enableDebugInfo = enableDebugInfo;
- })(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
/* @internal */
var ts;
@@ -68963,8 +69016,8 @@ var ts;
* @param receiver The receiver on which each property should be assigned.
*/
function addInitializedPropertyStatements(statements, properties, receiver) {
- for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
- var property = properties_7[_i];
+ for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) {
+ var property = properties_6[_i];
var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver));
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
ts.setCommentRange(statement, property);
@@ -68980,8 +69033,8 @@ var ts;
*/
function generateInitializedPropertyExpressions(properties, receiver) {
var expressions = [];
- for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
- var property = properties_8[_i];
+ for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
+ var property = properties_7[_i];
var expression = transformInitializedProperty(property, receiver);
ts.startOnNewLine(expression);
ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
@@ -71523,6 +71576,8 @@ var ts;
return visitObjectLiteralExpression(node);
case 205 /* BinaryExpression */:
return visitBinaryExpression(node, noDestructuringValue);
+ case 275 /* CatchClause */:
+ return visitCatchClause(node);
case 238 /* VariableDeclaration */:
return visitVariableDeclaration(node);
case 228 /* ForOfStatement */:
@@ -71659,6 +71714,23 @@ var ts;
}
return ts.visitEachChild(node, visitor, context);
}
+ function visitCatchClause(node) {
+ if (node.variableDeclaration &&
+ ts.isBindingPattern(node.variableDeclaration.name) &&
+ node.variableDeclaration.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) {
+ var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
+ var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*type*/ undefined, name);
+ var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
+ var block = ts.visitNode(node.block, visitor, ts.isBlock);
+ if (ts.some(visitedBindings)) {
+ block = ts.updateBlock(block, [
+ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings)
+ ].concat(block.statements));
+ }
+ return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block);
+ }
+ return ts.visitEachChild(node, visitor, context);
+ }
/**
* Visits a VariableDeclaration node with a binding pattern.
*
@@ -72802,62 +72874,63 @@ var ts;
HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block";
HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement";
HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock";
- HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement";
- HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper";
+ HierarchyFacts[HierarchyFacts["IterationContainer"] = 1024] = "IterationContainer";
+ HierarchyFacts[HierarchyFacts["ForStatement"] = 2048] = "ForStatement";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 4096] = "ForInOrForOfStatement";
+ HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 8192] = "ConstructorWithCapturedSuper";
// NOTE: do not add more ancestor flags without also updating AncestorFactsMask below.
// NOTE: when adding a new ancestor flag, be sure to update the subtree flags below.
//
// Ancestor masks
//
- HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 8191] = "AncestorFactsMask";
+ HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask";
// We are always in *some* kind of block scope, but only specific block-scope containers are
// top-level or Blocks.
HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes";
- HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes";
+ HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 7104] = "BlockScopeExcludes";
// A source file is a top-level block scope.
HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes";
- HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes";
+ HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 8064] = "SourceFileExcludes";
// Functions, methods, and accessors are both new lexical scopes and new block scopes.
HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes";
- HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 8094] = "FunctionExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes";
HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes";
- HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 8086] = "AsyncFunctionBodyExcludes";
+ HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes";
// Arrow functions are lexically scoped to their container, but are new block scopes.
HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes";
- HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 8064] = "ArrowFunctionExcludes";
+ HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 15232] = "ArrowFunctionExcludes";
// Constructors are both new lexical scopes and new block scopes. Constructors are also
// always considered non-static members of a class.
HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes";
- HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 8086] = "ConstructorExcludes";
+ HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes";
// 'do' and 'while' statements are not block scopes. We track that the subtree is contained
// within an IterationStatement to indicate whether the embedded statement is an
// IterationStatementBlock.
- HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes";
+ HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 1280] = "DoOrWhileStatementIncludes";
HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes";
// 'for' statements are new block scopes and have special handling for 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 3328] = "ForStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 5056] = "ForStatementExcludes";
// 'for-in' and 'for-of' statements are new block scopes and have special handling for
// 'let' declarations.
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes";
- HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 5376] = "ForInOrForOfStatementIncludes";
+ HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 3008] = "ForInOrForOfStatementExcludes";
// Blocks (other than function bodies) are new block scopes.
HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes";
- HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes";
+ HierarchyFacts[HierarchyFacts["BlockExcludes"] = 6976] = "BlockExcludes";
HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes";
- HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes";
+ HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 7104] = "IterationStatementBlockExcludes";
//
// Subtree facts
//
- HierarchyFacts[HierarchyFacts["NewTarget"] = 8192] = "NewTarget";
- HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 16384] = "CapturedLexicalThis";
+ HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget";
+ HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 32768] = "CapturedLexicalThis";
//
// Subtree masks
//
- HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -8192] = "SubtreeFactsMask";
+ HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask";
HierarchyFacts[HierarchyFacts["ArrowFunctionSubtreeExcludes"] = 0] = "ArrowFunctionSubtreeExcludes";
- HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 24576] = "FunctionSubtreeExcludes";
+ HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 49152] = "FunctionSubtreeExcludes";
})(HierarchyFacts || (HierarchyFacts = {}));
function transformES2015(context) {
var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
@@ -72906,7 +72979,7 @@ var ts;
*/
function enterSubtree(excludeFacts, includeFacts) {
var ancestorFacts = hierarchyFacts;
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 8191 /* AncestorFactsMask */;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */;
return ancestorFacts;
}
/**
@@ -72917,17 +72990,17 @@ var ts;
* @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated.
*/
function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -8192 /* SubtreeFactsMask */ | ancestorFacts;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts;
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
- return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0
+ return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0
&& node.kind === 231 /* ReturnStatement */
&& !node.expression;
}
function shouldVisitNode(node) {
return (node.transformFlags & 128 /* ContainsES2015 */) !== 0
|| convertedLoopState !== undefined
- || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
+ || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */)))
|| (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node))
|| (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0;
}
@@ -73044,7 +73117,7 @@ var ts;
}
}
function visitSourceFile(node) {
- var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
+ var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
var prologue = [];
var statements = [];
startLexicalEnvironment();
@@ -73071,7 +73144,7 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitCaseBlock(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -73098,7 +73171,7 @@ var ts;
}
function visitThisKeyword(node) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
if (convertedLoopState) {
if (hierarchyFacts & 2 /* ArrowFunction */) {
@@ -73341,7 +73414,7 @@ var ts;
function addConstructor(statements, node, extendsClauseElement) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8086 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
+ var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
var constructor = ts.getFirstConstructorWithBody(node);
var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
var constructorFunction = ts.createFunctionDeclaration(
@@ -73355,7 +73428,7 @@ var ts;
ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */);
}
statements.push(constructorFunction);
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
}
/**
@@ -73448,7 +73521,7 @@ var ts;
}
}
if (superCallExpression) {
- hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */;
+ hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
}
// visit the remaining statements
@@ -73752,7 +73825,7 @@ var ts;
* @param node A node.
*/
function insertCaptureThisForNodeIfNeeded(statements, node) {
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) {
insertCaptureThisForNode(statements, node, ts.createThis());
return true;
}
@@ -73770,7 +73843,7 @@ var ts;
ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
}
function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
- if (hierarchyFacts & 8192 /* NewTarget */) {
+ if (hierarchyFacts & 16384 /* NewTarget */) {
var newTarget = void 0;
switch (node.kind) {
case 198 /* ArrowFunction */:
@@ -73940,11 +74013,11 @@ var ts;
*/
function visitArrowFunction(node) {
if (node.transformFlags & 2048 /* ContainsLexicalThis */) {
- hierarchyFacts |= 16384 /* CapturedLexicalThis */;
+ hierarchyFacts |= 32768 /* CapturedLexicalThis */;
}
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8064 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
+ var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
var func = ts.createFunctionExpression(
/*modifiers*/ undefined,
/*asteriskToken*/ undefined,
@@ -73954,7 +74027,7 @@ var ts;
ts.setTextRange(func, node);
ts.setOriginalNode(func, node);
ts.setEmitFlags(func, 8 /* CapturesThis */);
- if (hierarchyFacts & 16384 /* CapturedLexicalThis */) {
+ if (hierarchyFacts & 32768 /* CapturedLexicalThis */) {
enableSubstitutionsForCapturedThis();
}
// If an arrow function contains
@@ -73969,16 +74042,16 @@ var ts;
*/
function visitFunctionExpression(node) {
var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */
- ? enterSubtree(8086 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionExpression(node,
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -73993,13 +74066,13 @@ var ts;
function visitFunctionDeclaration(node) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 8192 /* NewTarget */
+ var name = hierarchyFacts & 16384 /* NewTarget */
? ts.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.updateFunctionDeclaration(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name,
@@ -74017,14 +74090,14 @@ var ts;
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */)
- ? enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
- : enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
+ : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- if (hierarchyFacts & 8192 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
+ if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) {
name = ts.getGeneratedNameForNode(node);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -74119,8 +74192,8 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */
- ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
- : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */);
+ ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
+ : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
@@ -74303,11 +74376,11 @@ var ts;
&& isDeclaredInLoop
&& (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0);
var emitExplicitInitializer = !emittedAsTopLevel
- && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0
+ && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0
&& (!resolver.isDeclarationWithCollidingName(node)
|| (isDeclaredInLoop
&& !isCapturedInFunction
- && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0));
+ && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0));
return emitExplicitInitializer;
}
/**
@@ -74378,21 +74451,21 @@ var ts;
}
function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
- var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert);
+ var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
return updated;
}
function visitDoOrWhileStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
}
function visitForStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement);
}
function visitForInStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
}
function visitForOfStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
+ return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
}
function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
var statements = [];
@@ -74500,7 +74573,7 @@ var ts;
ts.setTextRange(forStatement, node);
return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
}
- function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) {
+ function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined);
var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined);
@@ -74511,9 +74584,13 @@ var ts;
var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []);
hoistVariableDeclaration(errorRecord);
hoistVariableDeclaration(returnMethod);
+ // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration
+ var initializer = ancestorFacts & 1024 /* IterationContainer */
+ ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
+ : values;
var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(
/*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
- ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression),
+ ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, initializer), node.expression),
ts.createVariableDeclaration(result, /*type*/ undefined, next)
]), node.expression), 2097152 /* NoHoisting */),
/*condition*/ ts.createLogicalNot(ts.createPropertyAccess(result, "done")),
@@ -74624,7 +74701,7 @@ var ts;
}
}
}
- function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) {
+ function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
if (!shouldConvertIterationStatement(node)) {
var saveAllowedNonLabeledJumps = void 0;
if (convertedLoopState) {
@@ -74634,7 +74711,7 @@ var ts;
convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */;
}
var result = convert
- ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined)
+ ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts)
: ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
if (convertedLoopState) {
convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
@@ -74659,7 +74736,7 @@ var ts;
var loop;
if (bodyFunction) {
if (convert) {
- loop = convert(node, outermostLabeledStatement, bodyFunction.part);
+ loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
}
else {
var clone_3 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, /*multiLine*/ true));
@@ -75177,7 +75254,7 @@ var ts;
return expression;
}
function visitCatchClause(node) {
- var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
var updated;
ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
if (ts.isBindingPattern(node.variableDeclaration.name)) {
@@ -75225,7 +75302,7 @@ var ts;
ts.Debug.assert(!ts.isComputedPropertyName(node.name));
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */);
var updated;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
@@ -75235,7 +75312,7 @@ var ts;
else {
updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
}
- exitSubtree(ancestorFacts, 24576 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */);
convertedLoopState = savedConvertedLoopState;
return updated;
}
@@ -75721,7 +75798,7 @@ var ts;
}
function visitMetaProperty(node) {
if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") {
- hierarchyFacts |= 8192 /* NewTarget */;
+ hierarchyFacts |= 16384 /* NewTarget */;
return ts.createFileLevelUniqueName("_newTarget");
}
return node;
@@ -75736,7 +75813,7 @@ var ts;
function onEmitNode(hint, node, emitCallback) {
if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) {
// If we are tracking a captured `this`, keep track of the enclosing function.
- var ancestorFacts = enterSubtree(8094 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
+ var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
? 65 /* FunctionIncludes */ | 16 /* CapturesThis */
: 65 /* FunctionIncludes */);
previousOnEmitNode(hint, node, emitCallback);
@@ -87670,6 +87747,8 @@ var ts;
case 159 /* GetAccessor */:
case 160 /* SetAccessor */:
return generateNameForMethodOrAccessor(node);
+ case 150 /* ComputedPropertyName */:
+ return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true);
default:
return makeTempVariableName(0 /* Auto */);
}
@@ -90361,7 +90440,10 @@ var ts;
if (isRedirect) {
inputName = getProjectReferenceRedirect(fileName) || fileName;
}
- if (ts.getNormalizedAbsolutePath(checkedName, currentDirectory) !== ts.getNormalizedAbsolutePath(inputName, currentDirectory)) {
+ // Check if it differs only in drive letters its ok to ignore that error:
+ var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
+ var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory);
+ if (checkedAbsolutePath !== inputAbsolutePath) {
reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd);
}
}
@@ -90897,10 +90979,10 @@ var ts;
if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
}
- var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
+ var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
- programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
+ programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
@@ -93301,11 +93383,11 @@ var ts;
}
function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
var result = ts.createMap();
- var symlinks = ts.mapDefined(files, function (sf) {
- return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) {
+ var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
+ return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
- });
- });
+ })));
+ }));
for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];