diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-11-24 09:31:10 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-24 09:31:10 +1100 |
commit | 276f5297556097461e0b63f2b958d825c1c857ab (patch) | |
tree | c4146607a4646968d03ef804ec573133b2547553 /cli/tsc/00_typescript.js | |
parent | 266925d772527c9ba5fbc094e67cade31fc35a47 (diff) |
feat(cli): update to TypeScript 4.1 (#7573)
Diffstat (limited to 'cli/tsc/00_typescript.js')
-rw-r--r-- | cli/tsc/00_typescript.js | 20686 |
1 files changed, 11939 insertions, 8747 deletions
diff --git a/cli/tsc/00_typescript.js b/cli/tsc/00_typescript.js index 902286ac2..a3c7e0720 100644 --- a/cli/tsc/00_typescript.js +++ b/cli/tsc/00_typescript.js @@ -286,9 +286,9 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "4.0"; + ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.0.5"; + ts.version = "4.1.2"; /* @internal */ var Comparison; (function (Comparison) { @@ -1381,7 +1381,7 @@ var ts; var high = array.length - 1; while (low <= high) { var middle = low + ((high - low) >> 1); - var midKey = keySelector(array[middle]); + var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { case -1 /* LessThan */: low = middle + 1; @@ -1476,15 +1476,14 @@ var ts; return values; } ts.getOwnValues = getOwnValues; - var _entries = Object.entries ? Object.entries : function (obj) { + var _entries = Object.entries || (function (obj) { var keys = getOwnKeys(obj); var result = Array(keys.length); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - result.push([key, obj[key]]); + for (var i = 0; i < keys.length; i++) { + result[i] = [keys[i], obj[keys[i]]]; } return result; - }; + }); function getEntries(obj) { return obj ? _entries(obj) : []; } @@ -2356,20 +2355,39 @@ var ts; } } } - function padLeft(s, length) { - while (s.length < length) { - s = " " + s; - } - return s; + /** + * Returns string left-padded with spaces or zeros until it reaches the given length. + * + * @param s String to pad. + * @param length Final padded length. If less than or equal to 's.length', returns 's' unchanged. + * @param padString Character to use as padding (default " "). + */ + function padLeft(s, length, padString) { + if (padString === void 0) { padString = " "; } + return length <= s.length ? s : padString.repeat(length - s.length) + s; } ts.padLeft = padLeft; - function padRight(s, length) { - while (s.length < length) { - s = s + " "; - } - return s; + /** + * Returns string right-padded with spaces until it reaches the given length. + * + * @param s String to pad. + * @param length Final padded length. If less than or equal to 's.length', returns 's' unchanged. + * @param padString Character to use as padding (default " "). + */ + function padRight(s, length, padString) { + if (padString === void 0) { padString = " "; } + return length <= s.length ? s : s + padString.repeat(length - s.length); } ts.padRight = padRight; + function takeWhile(array, predicate) { + var len = array.length; + var index = 0; + while (index < len && predicate(array[index])) { + index++; + } + return array.slice(0, index); + } + ts.takeWhile = takeWhile; })(ts || (ts = {})); /* @internal */ var ts; @@ -2684,6 +2702,10 @@ var ts; return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true); } Debug.formatObjectFlags = formatObjectFlags; + function formatFlowFlags(flags) { + return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true); + } + Debug.formatFlowFlags = formatFlowFlags; var isDebugInfoEnabled = false; var extendedDebugModule; function extendedDebug() { @@ -2701,31 +2723,167 @@ var ts; return extendedDebug().formatControlFlowGraph(flowNode); } Debug.formatControlFlowGraph = formatControlFlowGraph; + var flowNodeProto; + function attachFlowNodeDebugInfoWorker(flowNode) { + if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line no-in-operator + Object.defineProperties(flowNode, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value: function () { + var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : + this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* Assignment */ ? "FlowAssignment" : + this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* Call */ ? "FlowCall" : + this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + "UnknownFlow"; + var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); + return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + } + }, + __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, + __debugToString: { value: function () { return formatControlFlowGraph(this); } } + }); + } + } function attachFlowNodeDebugInfo(flowNode) { if (isDebugInfoEnabled) { - if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line no-in-operator - Object.defineProperties(flowNode, { - __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, - __debugToString: { value: function () { return formatControlFlowGraph(this); } } - }); + if (typeof Object.setPrototypeOf === "function") { + // if we're in es2015, attach the method to a shared prototype for `FlowNode` + // so the method doesn't show up in the watch window. + if (!flowNodeProto) { + flowNodeProto = Object.create(Object.prototype); + attachFlowNodeDebugInfoWorker(flowNodeProto); + } + Object.setPrototypeOf(flowNode, flowNodeProto); + } + else { + // not running in an es2015 environment, attach the method directly. + attachFlowNodeDebugInfoWorker(flowNode); } } } Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo; + var nodeArrayProto; + function attachNodeArrayDebugInfoWorker(array) { + if (!("__tsDebuggerDisplay" in array)) { // eslint-disable-line no-in-operator + Object.defineProperties(array, { + __tsDebuggerDisplay: { + value: function (defaultValue) { + // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of + // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the + // formatted string. + defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); + return "NodeArray " + defaultValue; + } + } + }); + } + } + function attachNodeArrayDebugInfo(array) { + if (isDebugInfoEnabled) { + if (typeof Object.setPrototypeOf === "function") { + // if we're in es2015, attach the method to a shared prototype for `NodeArray` + // so the method doesn't show up in the watch window. + if (!nodeArrayProto) { + nodeArrayProto = Object.create(Array.prototype); + attachNodeArrayDebugInfoWorker(nodeArrayProto); + } + Object.setPrototypeOf(array, nodeArrayProto); + } + else { + // not running in an es2015 environment, attach the method directly. + attachNodeArrayDebugInfoWorker(array); + } + } + } + Debug.attachNodeArrayDebugInfo = attachNodeArrayDebugInfo; /** * Injects debug information into frequently used types. */ function enableDebugInfo() { if (isDebugInfoEnabled) return; + // avoid recomputing + var weakTypeTextMap; + var weakNodeTextMap; + function getWeakTypeTextMap() { + if (weakTypeTextMap === undefined) { + if (typeof WeakMap === "function") + weakTypeTextMap = new WeakMap(); + } + return weakTypeTextMap; + } + function getWeakNodeTextMap() { + if (weakNodeTextMap === undefined) { + if (typeof WeakMap === "function") + weakNodeTextMap = new WeakMap(); + } + return weakNodeTextMap; + } // Add additional properties in debug mode to assist with debugging. Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value: function () { + var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + "Symbol"; + var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; + return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + } + }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value: function () { + var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : + this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : + this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : + this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* Enum */ ? "EnumType" : + this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : + this.flags & 1048576 /* Union */ ? "UnionType" : + this.flags & 2097152 /* Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* Index */ ? "IndexType" : + this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* Object */ ? + this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* Reference */ ? "TypeReference" : + this.objectFlags & 8 /* Tuple */ ? "TupleType" : + this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* Mapped */ ? "MappedType" : + this.objectFlags & 2048 /* ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + "ObjectType" : + "Type"; + var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~2367 /* ObjectTypeKindMask */ : 0; + return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + } + }, __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); } }, + __debugTypeToString: { + value: function () { + // avoid recomputing + var map = getWeakTypeTextMap(); + var text = map === null || map === void 0 ? void 0 : map.get(this); + if (text === undefined) { + text = this.checker.typeToString(this); + map === null || map === void 0 ? void 0 : map.set(this, text); + } + return text; + } + }, }); var nodeConstructors = [ ts.objectAllocator.getNodeConstructor(), @@ -2737,6 +2895,49 @@ var ts; var ctor = nodeConstructors_1[_i]; if (!ctor.prototype.hasOwnProperty("__debugKind")) { Object.defineProperties(ctor.prototype, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value: function () { + var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : + ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : + ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : + ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : + ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : + ts.isParameter(this) ? "ParameterDeclaration" : + ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : + ts.isGetAccessorDeclaration(this) ? "GetAccessorDeclaration" : + ts.isSetAccessorDeclaration(this) ? "SetAccessorDeclaration" : + ts.isCallSignatureDeclaration(this) ? "CallSignatureDeclaration" : + ts.isConstructSignatureDeclaration(this) ? "ConstructSignatureDeclaration" : + ts.isIndexSignatureDeclaration(this) ? "IndexSignatureDeclaration" : + ts.isTypePredicateNode(this) ? "TypePredicateNode" : + ts.isTypeReferenceNode(this) ? "TypeReferenceNode" : + ts.isFunctionTypeNode(this) ? "FunctionTypeNode" : + ts.isConstructorTypeNode(this) ? "ConstructorTypeNode" : + ts.isTypeQueryNode(this) ? "TypeQueryNode" : + ts.isTypeLiteralNode(this) ? "TypeLiteralNode" : + ts.isArrayTypeNode(this) ? "ArrayTypeNode" : + ts.isTupleTypeNode(this) ? "TupleTypeNode" : + ts.isOptionalTypeNode(this) ? "OptionalTypeNode" : + ts.isRestTypeNode(this) ? "RestTypeNode" : + ts.isUnionTypeNode(this) ? "UnionTypeNode" : + ts.isIntersectionTypeNode(this) ? "IntersectionTypeNode" : + ts.isConditionalTypeNode(this) ? "ConditionalTypeNode" : + ts.isInferTypeNode(this) ? "InferTypeNode" : + ts.isParenthesizedTypeNode(this) ? "ParenthesizedTypeNode" : + ts.isThisTypeNode(this) ? "ThisTypeNode" : + ts.isTypeOperatorNode(this) ? "TypeOperatorNode" : + ts.isIndexedAccessTypeNode(this) ? "IndexedAccessTypeNode" : + ts.isMappedTypeNode(this) ? "MappedTypeNode" : + ts.isLiteralTypeNode(this) ? "LiteralTypeNode" : + ts.isNamedTupleMember(this) ? "NamedTupleMember" : + ts.isImportTypeNode(this) ? "ImportTypeNode" : + formatSyntaxKind(this.kind); + return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + } + }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } }, __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getEffectiveModifierFlagsNoCache(this)); } }, @@ -2747,9 +2948,16 @@ var ts; 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) : ""; + // avoid recomputing + var map = getWeakNodeTextMap(); + var text = map === null || map === void 0 ? void 0 : map.get(this); + if (text === undefined) { + var parseNode = ts.getParseTreeNode(this); + var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode); + text = sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : ""; + map === null || map === void 0 ? void 0 : map.set(this, text); + } + return text; } } }); @@ -2821,168 +3029,6 @@ var ts; Debug.deprecate = deprecate; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); -/*@internal*/ -var ts; -(function (ts) { - /** Gets a timestamp with (at least) ms resolution */ - ts.timestamp = typeof performance !== "undefined" && performance.now ? function () { return performance.now(); } : Date.now ? Date.now : function () { return +(new Date()); }; -})(ts || (ts = {})); -/*@internal*/ -/** Performance measurements for the compiler. */ -var ts; -(function (ts) { - var performance; - (function (performance) { - // NOTE: cannot use ts.noop as core.ts loads after this - var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent : function () { }; - var enabled = false; - var profilerStart = 0; - var counts; - var marks; - var measures; - function createTimerIf(condition, measureName, startMarkName, endMarkName) { - return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; - } - performance.createTimerIf = createTimerIf; - function createTimer(measureName, startMarkName, endMarkName) { - var enterCount = 0; - return { - enter: enter, - exit: exit - }; - function enter() { - if (++enterCount === 1) { - mark(startMarkName); - } - } - function exit() { - if (--enterCount === 0) { - mark(endMarkName); - measure(measureName, startMarkName, endMarkName); - } - else if (enterCount < 0) { - ts.Debug.fail("enter/exit count does not match."); - } - } - } - performance.createTimer = createTimer; - performance.nullTimer = { enter: ts.noop, exit: ts.noop }; - /** - * Marks a performance event. - * - * @param markName The name of the mark. - */ - function mark(markName) { - if (enabled) { - marks.set(markName, ts.timestamp()); - counts.set(markName, (counts.get(markName) || 0) + 1); - profilerEvent(markName); - } - } - performance.mark = mark; - /** - * Adds a performance measurement with the specified name. - * - * @param measureName The name of the performance measurement. - * @param startMarkName The name of the starting mark. If not supplied, the point at which the - * profiler was enabled is used. - * @param endMarkName The name of the ending mark. If not supplied, the current timestamp is - * used. - */ - function measure(measureName, startMarkName, endMarkName) { - if (enabled) { - var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); - var start = startMarkName && marks.get(startMarkName) || profilerStart; - measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); - } - } - performance.measure = measure; - /** - * Gets the number of times a marker was encountered. - * - * @param markName The name of the mark. - */ - function getCount(markName) { - return counts && counts.get(markName) || 0; - } - performance.getCount = getCount; - /** - * Gets the total duration of all measurements with the supplied name. - * - * @param measureName The name of the measure whose durations should be accumulated. - */ - function getDuration(measureName) { - return measures && measures.get(measureName) || 0; - } - performance.getDuration = getDuration; - /** - * Iterate over each measure, performing some action - * - * @param cb The action to perform for each measure - */ - function forEachMeasure(cb) { - measures.forEach(function (measure, key) { - cb(key, measure); - }); - } - performance.forEachMeasure = forEachMeasure; - /** Enables (and resets) performance measurements for the compiler. */ - function enable() { - counts = new ts.Map(); - marks = new ts.Map(); - measures = new ts.Map(); - enabled = true; - profilerStart = ts.timestamp(); - } - performance.enable = enable; - /** Disables performance measurements for the compiler. */ - function disable() { - enabled = false; - } - performance.disable = disable; - })(performance = ts.performance || (ts.performance = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - var _a; - var nullLogger = { - logEvent: ts.noop, - logErrEvent: ts.noop, - logPerfEvent: ts.noop, - logInfoEvent: ts.noop, - logStartCommand: ts.noop, - logStopCommand: ts.noop, - logStartUpdateProgram: ts.noop, - logStopUpdateProgram: ts.noop, - logStartUpdateGraph: ts.noop, - logStopUpdateGraph: ts.noop, - logStartResolveModule: ts.noop, - logStopResolveModule: ts.noop, - logStartParseSourceFile: ts.noop, - logStopParseSourceFile: ts.noop, - logStartReadFile: ts.noop, - logStopReadFile: ts.noop, - logStartBindFile: ts.noop, - logStopBindFile: ts.noop, - logStartScheduledOperation: ts.noop, - logStopScheduledOperation: ts.noop, - }; - // Load optional module to enable Event Tracing for Windows - // See https://github.com/microsoft/typescript-etw for more information - var etwModule; - try { - var etwModulePath = (_a = process.env.TS_ETW_MODULE_PATH) !== null && _a !== void 0 ? _a : "./node_modules/@microsoft/typescript-etw"; - // require() will throw an exception if the module is not found - // It may also return undefined if not installed properly - etwModule = require(etwModulePath); - } - catch (e) { - etwModule = undefined; - } - /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ - ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; -})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -3059,7 +3105,7 @@ var ts; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) - || comparePrerelaseIdentifiers(this.prerelease, other.prerelease); + || comparePrereleaseIdentifiers(this.prerelease, other.prerelease); }; Version.prototype.increment = function (field) { switch (field) { @@ -3098,7 +3144,7 @@ var ts; build: build }; } - function comparePrerelaseIdentifiers(left, right) { + function comparePrereleaseIdentifiers(left, right) { // https://semver.org/#spec-item-11 // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. @@ -3343,6 +3389,485 @@ var ts; return "" + comparator.operator + comparator.operand; } })(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + // The following definitions provide the minimum compatible support for the Web Performance User Timings API + // between browsers and NodeJS: + // eslint-disable-next-line @typescript-eslint/naming-convention + function hasRequiredAPI(performance, PerformanceObserver) { + return typeof performance === "object" && + typeof performance.timeOrigin === "number" && + typeof performance.mark === "function" && + typeof performance.measure === "function" && + typeof performance.now === "function" && + typeof PerformanceObserver === "function"; + } + function tryGetWebPerformanceHooks() { + if (typeof performance === "object" && + typeof PerformanceObserver === "function" && + hasRequiredAPI(performance, PerformanceObserver)) { + return { + performance: performance, + PerformanceObserver: PerformanceObserver + }; + } + } + function tryGetNodePerformanceHooks() { + if (typeof module === "object" && typeof require === "function") { + try { + var _a = require("perf_hooks"), performance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; + if (hasRequiredAPI(performance_1, PerformanceObserver_1)) { + // There is a bug in Node's performance.measure prior to 12.16.3/13.13.0 that does not + // match the Web Performance API specification. Node's implementation did not allow + // optional `start` and `end` arguments for `performance.measure`. + // See https://github.com/nodejs/node/pull/32651 for more information. + var version_1 = new ts.Version(process.versions.node); + var range = new ts.VersionRange("<12.16.3 || 13 <13.13"); + if (range.test(version_1)) { + return { + performance: { + get timeOrigin() { return performance_1.timeOrigin; }, + now: function () { return performance_1.now(); }, + mark: function (name) { return performance_1.mark(name); }, + measure: function (name, start, end) { + if (start === void 0) { start = "nodeStart"; } + if (end === undefined) { + end = "__performance.measure-fix__"; + performance_1.mark(end); + } + performance_1.measure(name, start, end); + if (end === "__performance.measure-fix__") { + performance_1.clearMarks("__performance.measure-fix__"); + } + } + }, + PerformanceObserver: PerformanceObserver_1 + }; + } + return { + performance: performance_1, + PerformanceObserver: PerformanceObserver_1 + }; + } + } + catch (_b) { + // ignore errors + } + } + } + // Unlike with the native Map/Set 'tryGet' functions in corePublic.ts, we eagerly evaluate these + // since we will need them for `timestamp`, below. + var nativePerformanceHooks = tryGetWebPerformanceHooks() || tryGetNodePerformanceHooks(); + var nativePerformance = nativePerformanceHooks === null || nativePerformanceHooks === void 0 ? void 0 : nativePerformanceHooks.performance; + function tryGetNativePerformanceHooks() { + return nativePerformanceHooks; + } + ts.tryGetNativePerformanceHooks = tryGetNativePerformanceHooks; + /** Gets a timestamp with (at least) ms resolution */ + ts.timestamp = nativePerformance ? function () { return nativePerformance.now(); } : + Date.now ? Date.now : + function () { return +(new Date()); }; +})(ts || (ts = {})); +/*@internal*/ +/** Performance measurements for the compiler. */ +var ts; +(function (ts) { + var performance; + (function (performance) { + var perfHooks; + var perfObserver; + // when set, indicates the implementation of `Performance` to use for user timing. + // when unset, indicates user timing is unavailable or disabled. + var performanceImpl; + function createTimerIf(condition, measureName, startMarkName, endMarkName) { + return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; + } + performance.createTimerIf = createTimerIf; + function createTimer(measureName, startMarkName, endMarkName) { + var enterCount = 0; + return { + enter: enter, + exit: exit + }; + function enter() { + if (++enterCount === 1) { + mark(startMarkName); + } + } + function exit() { + if (--enterCount === 0) { + mark(endMarkName); + measure(measureName, startMarkName, endMarkName); + } + else if (enterCount < 0) { + ts.Debug.fail("enter/exit count does not match."); + } + } + } + performance.createTimer = createTimer; + performance.nullTimer = { enter: ts.noop, exit: ts.noop }; + var counts = new ts.Map(); + var durations = new ts.Map(); + /** + * Marks a performance event. + * + * @param markName The name of the mark. + */ + function mark(markName) { + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + } + performance.mark = mark; + /** + * Adds a performance measurement with the specified name. + * + * @param measureName The name of the performance measurement. + * @param startMarkName The name of the starting mark. If not supplied, the point at which the + * profiler was enabled is used. + * @param endMarkName The name of the ending mark. If not supplied, the current timestamp is + * used. + */ + function measure(measureName, startMarkName, endMarkName) { + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + } + performance.measure = measure; + /** + * Gets the number of times a marker was encountered. + * + * @param markName The name of the mark. + */ + function getCount(markName) { + return counts.get(markName) || 0; + } + performance.getCount = getCount; + /** + * Gets the total duration of all measurements with the supplied name. + * + * @param measureName The name of the measure whose durations should be accumulated. + */ + function getDuration(measureName) { + return durations.get(measureName) || 0; + } + performance.getDuration = getDuration; + /** + * Iterate over each measure, performing some action + * + * @param cb The action to perform for each measure + */ + function forEachMeasure(cb) { + durations.forEach(function (duration, measureName) { return cb(measureName, duration); }); + } + performance.forEachMeasure = forEachMeasure; + /** + * Indicates whether the performance API is enabled. + */ + function isEnabled() { + return !!performanceImpl; + } + performance.isEnabled = isEnabled; + /** Enables (and resets) performance measurements for the compiler. */ + function enable() { + if (!performanceImpl) { + perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks()); + if (!perfHooks) + return false; + perfObserver || (perfObserver = new perfHooks.PerformanceObserver(updateStatisticsFromList)); + perfObserver.observe({ entryTypes: ["mark", "measure"] }); + performanceImpl = perfHooks.performance; + } + return true; + } + performance.enable = enable; + /** Disables performance measurements for the compiler. */ + function disable() { + perfObserver === null || perfObserver === void 0 ? void 0 : perfObserver.disconnect(); + performanceImpl = undefined; + counts.clear(); + durations.clear(); + } + performance.disable = disable; + function updateStatisticsFromList(list) { + for (var _i = 0, _a = list.getEntriesByType("mark"); _i < _a.length; _i++) { + var mark_1 = _a[_i]; + counts.set(mark_1.name, (counts.get(mark_1.name) || 0) + 1); + } + for (var _b = 0, _c = list.getEntriesByType("measure"); _b < _c.length; _b++) { + var measure_1 = _c[_b]; + durations.set(measure_1.name, (durations.get(measure_1.name) || 0) + measure_1.duration); + } + } + })(performance = ts.performance || (ts.performance = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var _a; + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + var etwModulePath = (_a = process.env.TS_ETW_MODULE_PATH) !== null && _a !== void 0 ? _a : "./node_modules/@microsoft/typescript-etw"; + // require() will throw an exception if the module is not found + // It may also return undefined if not installed properly + etwModule = require(etwModulePath); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; +})(ts || (ts = {})); +/*@internal*/ +/** Tracing events for the compiler. */ +var ts; +(function (ts) { + var tracing; + (function (tracing) { + var fs; + var traceCount = 0; + var traceFd; + var legendPath; + var legend = []; + /** Starts tracing for the given project (unless the `fs` module is unavailable). */ + function startTracing(configFilePath, traceDir, isBuildMode) { + ts.Debug.assert(!traceFd, "Tracing already started"); + if (fs === undefined) { + try { + fs = require("fs"); + } + catch (_a) { + fs = false; + } + } + if (!fs) { + return; + } + if (legendPath === undefined) { + legendPath = ts.combinePaths(traceDir, "legend.json"); + } + // Note that writing will fail later on if it exists and is not a directory + if (!fs.existsSync(traceDir)) { + fs.mkdirSync(traceDir, { recursive: true }); + } + var countPart = isBuildMode ? "." + ++traceCount : ""; + var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); + var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + legend.push({ + configFilePath: configFilePath, + tracePath: tracePath, + typesPath: typesPath, + }); + traceFd = fs.openSync(tracePath, "w"); + // Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import) + var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 }; + fs.writeSync(traceFd, "[\n" + + [__assign({ name: "process_name", args: { name: "tsc" } }, meta), __assign({ name: "thread_name", args: { name: "Main" } }, meta), __assign(__assign({ name: "TracingStartedInBrowser" }, meta), { cat: "disabled-by-default-devtools.timeline" })] + .map(function (v) { return JSON.stringify(v); }).join(",\n")); + } + tracing.startTracing = startTracing; + /** Stops tracing for the in-progress project and dumps the type catalog (unless the `fs` module is unavailable). */ + function stopTracing(typeCatalog) { + if (!traceFd) { + ts.Debug.assert(!fs, "Tracing is not in progress"); + return; + } + ts.Debug.assert(fs); + fs.writeSync(traceFd, "\n]\n"); + fs.closeSync(traceFd); + traceFd = undefined; + if (typeCatalog) { + dumpTypes(typeCatalog); + } + else { + // We pre-computed this path for convenience, but clear it + // now that the file won't be created. + legend[legend.length - 1].typesPath = undefined; + } + } + tracing.stopTracing = stopTracing; + function isTracing() { + return !!traceFd; + } + tracing.isTracing = isTracing; + var Phase; + (function (Phase) { + Phase["Parse"] = "parse"; + Phase["Program"] = "program"; + Phase["Bind"] = "bind"; + Phase["Check"] = "check"; + Phase["Emit"] = "emit"; + })(Phase = tracing.Phase || (tracing.Phase = {})); + /** Note: `push`/`pop` should be used by default. + * `begin`/`end` are for special cases where we need the data point even if the event never + * terminates (typically for reducing a scenario too big to trace to one that can be completed). + * In the future we might implement an exit handler to dump unfinished events which would + * deprecate these operations. + */ + function begin(phase, name, args) { + if (!traceFd) + return; + writeEvent("B", phase, name, args); + } + tracing.begin = begin; + function end(phase, name, args) { + if (!traceFd) + return; + writeEvent("E", phase, name, args); + } + tracing.end = end; + function instant(phase, name, args) { + if (!traceFd) + return; + writeEvent("I", phase, name, args, "\"s\":\"g\""); + } + tracing.instant = instant; + // Used for "Complete" (ph:"X") events + var completeEvents = []; + function push(phase, name, args) { + if (!traceFd) + return; + completeEvents.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp() }); + } + tracing.push = push; + function pop() { + if (!traceFd) + return; + ts.Debug.assert(completeEvents.length > 0); + var _a = completeEvents.pop(), phase = _a.phase, name = _a.name, args = _a.args, time = _a.time; + var dur = 1000 * ts.timestamp() - time; + writeEvent("X", phase, name, args, "\"dur\":" + dur, time); + } + tracing.pop = pop; + function writeEvent(eventType, phase, name, args, extras, time) { + if (time === void 0) { time = 1000 * ts.timestamp(); } + ts.Debug.assert(traceFd); + ts.Debug.assert(fs); + ts.performance.mark("beginTracing"); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + if (extras) + fs.writeSync(traceFd, "," + extras); + if (args) + fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, "}"); + ts.performance.mark("endTracing"); + ts.performance.measure("Tracing", "beginTracing", "endTracing"); + } + function indexFromOne(lc) { + return { + line: lc.line + 1, + character: lc.character + 1, + }; + } + function dumpTypes(types) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; + ts.Debug.assert(fs); + ts.performance.mark("beginDumpTypes"); + var typesPath = legend[legend.length - 1].typesPath; + var typesFd = fs.openSync(typesPath, "w"); + var recursionIdentityMap = new ts.Map(); + // Cleverness: no line break here so that the type ID will match the line number + fs.writeSync(typesFd, "["); + var numTypes = types.length; + for (var i = 0; i < numTypes; i++) { + var type = types[i]; + var objectFlags = type.objectFlags; + var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; + var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0]; + var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration); + // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) + var display = void 0; + if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + try { + display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type); + } + catch (_s) { + display = undefined; + } + } + var indexedAccessProperties = {}; + if (type.flags & 8388608 /* IndexedAccess */) { + var indexedAccessType = type; + indexedAccessProperties = { + indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id, + indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id, + }; + } + var referenceProperties = {}; + if (objectFlags & 4 /* Reference */) { + var referenceType = type; + referenceProperties = { + instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id, + typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }), + }; + } + var conditionalProperties = {}; + if (type.flags & 16777216 /* Conditional */) { + var conditionalType = type; + conditionalProperties = { + conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id, + conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id, + conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1, + conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1, + }; + } + // We can't print out an arbitrary object, so just assign each one a unique number. + // Don't call it an "id" so people don't treat it as a type id. + var recursionToken = void 0; + var recursionIdentity = type.checker.getRecursionIdentity(type); + if (recursionIdentity) { + recursionToken = recursionIdentityMap.get(recursionIdentity); + if (!recursionToken) { + recursionToken = recursionIdentityMap.size; + recursionIdentityMap.set(recursionIdentity, recursionToken); + } + } + var descriptor = __assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, unionTypes: (type.flags & 1048576 /* Union */) ? (_p = type.types) === null || _p === void 0 ? void 0 : _p.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_q = type.aliasTypeArguments) === null || _q === void 0 ? void 0 : _q.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_r = type.type) === null || _r === void 0 ? void 0 : _r.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), { firstDeclaration: firstDeclaration && { + path: firstFile.path, + start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)), + end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)), + }, flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + fs.writeSync(typesFd, JSON.stringify(descriptor)); + if (i < numTypes - 1) { + fs.writeSync(typesFd, ",\n"); + } + } + fs.writeSync(typesFd, "]\n"); + fs.closeSync(typesFd); + ts.performance.mark("endDumpTypes"); + ts.performance.measure("Dump types", "beginDumpTypes", "endDumpTypes"); + } + function dumpLegend() { + if (!legendPath) { + return; + } + ts.Debug.assert(fs); + fs.writeFileSync(legendPath, JSON.stringify(legend)); + } + tracing.dumpLegend = dumpLegend; + })(tracing = ts.tracing || (ts.tracing = {})); +})(ts || (ts = {})); var ts; (function (ts) { // token > SyntaxKind.Identifier => token is a keyword @@ -3497,230 +4022,235 @@ var ts; SyntaxKind[SyntaxKind["DeclareKeyword"] = 133] = "DeclareKeyword"; SyntaxKind[SyntaxKind["GetKeyword"] = 134] = "GetKeyword"; SyntaxKind[SyntaxKind["InferKeyword"] = 135] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 136] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 137] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 138] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 139] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 140] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 141] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 142] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 143] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 144] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 145] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 146] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 147] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 148] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 149] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 150] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 151] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 152] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 153] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 154] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 155] = "OfKeyword"; + SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 136] = "IntrinsicKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 137] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 138] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 139] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 140] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 141] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 142] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 143] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 144] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 145] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 146] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 147] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 148] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 149] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 150] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 151] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 152] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 153] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 154] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 155] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 156] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 156] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 157] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 157] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 158] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 158] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 159] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 160] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 159] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 160] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 161] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 161] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 162] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 163] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 164] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 165] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 166] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 167] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 168] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 169] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 170] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 162] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 163] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 164] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 165] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 166] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 167] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 168] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 169] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 170] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 171] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 171] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 172] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 173] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 174] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 175] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 176] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 177] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 178] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 179] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 180] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 181] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 182] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 183] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 184] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 185] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 186] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 187] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 188] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 189] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 190] = "LiteralType"; - SyntaxKind[SyntaxKind["NamedTupleMember"] = 191] = "NamedTupleMember"; - SyntaxKind[SyntaxKind["ImportType"] = 192] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 172] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 173] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 174] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 175] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 176] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 177] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 178] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 179] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 180] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 181] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 182] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 183] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 184] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 185] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 186] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 187] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 188] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 189] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 190] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 191] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 192] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 193] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 194] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 195] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 193] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 194] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 195] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 196] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 197] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 198] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 196] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 197] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 198] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 199] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 200] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 201] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 202] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 203] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 204] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 205] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 206] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 207] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 208] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 209] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 210] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 211] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 212] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 213] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 214] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 215] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 216] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 217] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 218] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 219] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 220] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 221] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 222] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 223] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 224] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 199] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 200] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 201] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 202] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 203] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 204] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 205] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 206] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 207] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 208] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 209] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 210] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 211] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 212] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 213] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 214] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 215] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 216] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 217] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 218] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 219] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 220] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 221] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 223] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 224] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 225] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 226] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 227] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 225] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 226] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 228] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 229] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 227] = "Block"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 228] = "EmptyStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 229] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 230] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 231] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 232] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 233] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 234] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 235] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 236] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 237] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 238] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 239] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 240] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 241] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 242] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 243] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 244] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 245] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 246] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 247] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 248] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 249] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 250] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 251] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 252] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 253] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 254] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 255] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 256] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 257] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 258] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 259] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 260] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 261] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 262] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 263] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 264] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 265] = "NamedExports"; - SyntaxKind[SyntaxKind["NamespaceExport"] = 266] = "NamespaceExport"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 267] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 268] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 230] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 231] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 232] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 233] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 234] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 235] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 236] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 237] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 238] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 239] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 240] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 241] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 242] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 243] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 244] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 245] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 246] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 247] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 248] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 249] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 250] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 251] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 252] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 253] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 254] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 255] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 256] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 257] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 258] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 259] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 260] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 261] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 262] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 263] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 264] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 265] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 266] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 267] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 268] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 269] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 270] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 271] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 269] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 272] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 270] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 271] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 272] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 273] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 274] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 275] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 276] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 277] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 278] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 279] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 280] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 273] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 274] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 275] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 276] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 277] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 278] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 279] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 280] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 281] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 282] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 283] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 281] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 282] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 283] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 284] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 284] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 285] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 286] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 287] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 285] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 286] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 287] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 288] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 289] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 290] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 288] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 291] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 289] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 290] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 291] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 292] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 293] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 292] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 293] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 294] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 295] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 296] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 294] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 295] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 296] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 297] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 297] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 298] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 299] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 300] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 298] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 301] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 302] = "JSDocNameReference"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 299] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 303] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 300] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 301] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 302] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 303] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 304] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 305] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 304] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 305] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 306] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 307] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 308] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 309] = "JSDocVariadicType"; // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 306] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 307] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 308] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 309] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 310] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 311] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 312] = "JSDocImplementsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 313] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 314] = "JSDocDeprecatedTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 315] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocPublicTag"] = 316] = "JSDocPublicTag"; - SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 317] = "JSDocPrivateTag"; - SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 318] = "JSDocProtectedTag"; - SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 319] = "JSDocReadonlyTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 320] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 321] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 322] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 323] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 324] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 325] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 326] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 327] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 328] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 310] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 311] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 312] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 313] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 314] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 315] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 316] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 317] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 318] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 319] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 320] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 321] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 322] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 323] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 324] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 325] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 326] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 327] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 328] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 329] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 330] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 331] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 332] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 333] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 329] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 334] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 330] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 331] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 332] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 333] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 334] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 335] = "SyntheticReferenceExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 335] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 336] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 337] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 338] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 339] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 340] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 336] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 341] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 77] = "LastAssignment"; @@ -3729,15 +4259,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 80] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 115] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 80] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 155] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 156] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 116] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 124] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 171] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 192] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 172] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 195] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 77] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 155] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 156] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -3746,15 +4276,15 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 77] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstStatement"] = 229] = "FirstStatement"; - SyntaxKind[SyntaxKind["LastStatement"] = 245] = "LastStatement"; - SyntaxKind[SyntaxKind["FirstNode"] = 156] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 298] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 328] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 310] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 328] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstStatement"] = 232] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 248] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 157] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 301] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 333] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 314] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 333] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 125] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 155] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 156] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3865,6 +4395,7 @@ var ts; GeneratedIdentifierFlags[GeneratedIdentifierFlags["ReservedInNestedScopes"] = 8] = "ReservedInNestedScopes"; GeneratedIdentifierFlags[GeneratedIdentifierFlags["Optimistic"] = 16] = "Optimistic"; GeneratedIdentifierFlags[GeneratedIdentifierFlags["FileLevel"] = 32] = "FileLevel"; + GeneratedIdentifierFlags[GeneratedIdentifierFlags["AllowNameSubstitution"] = 64] = "AllowNameSubstitution"; })(GeneratedIdentifierFlags = ts.GeneratedIdentifierFlags || (ts.GeneratedIdentifierFlags = {})); var TokenFlags; (function (TokenFlags) { @@ -4308,6 +4839,8 @@ var ts; TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; + TypeFlags[TypeFlags["TemplateLiteral"] = 134217728] = "TemplateLiteral"; + TypeFlags[TypeFlags["StringMapping"] = 268435456] = "StringMapping"; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ @@ -4324,7 +4857,7 @@ var ts; TypeFlags[TypeFlags["Intrinsic"] = 67359327] = "Intrinsic"; /* @internal */ TypeFlags[TypeFlags["Primitive"] = 131068] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 132] = "StringLike"; + TypeFlags[TypeFlags["StringLike"] = 402653316] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 296] = "NumberLike"; TypeFlags[TypeFlags["BigIntLike"] = 2112] = "BigIntLike"; TypeFlags[TypeFlags["BooleanLike"] = 528] = "BooleanLike"; @@ -4332,28 +4865,28 @@ var ts; TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike"; TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike"; /* @internal */ - TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; + TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains"; TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 465829888] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable"; /* @internal */ TypeFlags[TypeFlags["ObjectFlagsType"] = 3899393] = "ObjectFlagsType"; /* @internal */ TypeFlags[TypeFlags["Simplifiable"] = 25165824] = "Simplifiable"; /* @internal */ - TypeFlags[TypeFlags["Substructure"] = 66584576] = "Substructure"; + TypeFlags[TypeFlags["Substructure"] = 469237760] = "Substructure"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["Narrowable"] = 536624127] = "Narrowable"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 469647395] = "NotPrimitiveUnion"; // The following flags are aggregated during union and intersection type construction /* @internal */ - TypeFlags[TypeFlags["IncludesMask"] = 71041023] = "IncludesMask"; + TypeFlags[TypeFlags["IncludesMask"] = 205258751] = "IncludesMask"; // The following flags are used for different purposes during union and intersection type construction /* @internal */ TypeFlags[TypeFlags["IncludesStructuredOrInstantiable"] = 262144] = "IncludesStructuredOrInstantiable"; @@ -4410,11 +4943,16 @@ var ts; ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 268435456] = "IsNeverIntersectionComputed"; /* @internal */ ObjectFlags[ObjectFlags["IsNeverIntersection"] = 536870912] = "IsNeverIntersection"; + /* @internal */ + ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 1073741824] = "IsClassInstanceClone"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; /* @internal */ ObjectFlags[ObjectFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; /* @internal */ ObjectFlags[ObjectFlags["PropagatingFlags"] = 3670016] = "PropagatingFlags"; + // Object flags that uniquely identify the kind of ObjectType + /* @internal */ + ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 2367] = "ObjectTypeKindMask"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ var VarianceFlags; @@ -4504,18 +5042,18 @@ var ts; })(InferenceFlags = ts.InferenceFlags || (ts.InferenceFlags = {})); /** * Ternary values are defined such that - * x & y is False if either x or y is False. - * x & y is Maybe if either x or y is Maybe, but neither x or y is False. - * x & y is True if both x and y are True. - * x | y is False if both x and y are False. - * x | y is Maybe if either x or y is Maybe, but neither x or y is True. - * x | y is True if either x or y is True. + * x & y picks the lesser in the order False < Unknown < Maybe < True, and + * x | y picks the greater in the order False < Unknown < Maybe < True. + * Generally, Ternary.Maybe is used as the result of a relation that depends on itself, and + * Ternary.Unknown is used as the result of a variance check that depends on itself. We make + * a distinction because we don't want to cache circular variance check results. */ /* @internal */ var Ternary; (function (Ternary) { Ternary[Ternary["False"] = 0] = "False"; - Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["Unknown"] = 1] = "Unknown"; + Ternary[Ternary["Maybe"] = 3] = "Maybe"; Ternary[Ternary["True"] = -1] = "True"; })(Ternary = ts.Ternary || (ts.Ternary = {})); /* @internal */ @@ -4523,6 +5061,7 @@ var ts; (function (AssignmentDeclarationKind) { AssignmentDeclarationKind[AssignmentDeclarationKind["None"] = 0] = "None"; /// exports.name = expr + /// module.exports.name = expr AssignmentDeclarationKind[AssignmentDeclarationKind["ExportsProperty"] = 1] = "ExportsProperty"; /// module.exports = expr AssignmentDeclarationKind[AssignmentDeclarationKind["ModuleExports"] = 2] = "ModuleExports"; @@ -4603,6 +5142,8 @@ var ts; JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; JsxEmit[JsxEmit["React"] = 2] = "React"; JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; + JsxEmit[JsxEmit["ReactJSX"] = 4] = "ReactJSX"; + JsxEmit[JsxEmit["ReactJSXDev"] = 5] = "ReactJSXDev"; })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); var ImportsNotUsedAsValues; (function (ImportsNotUsedAsValues) { @@ -5121,8 +5662,696 @@ var ts; args: [{ name: "factory" }], kind: 4 /* MultiLine */ }, + "jsximportsource": { + args: [{ name: "factory" }], + kind: 4 /* MultiLine */ + }, + "jsxruntime": { + args: [{ name: "factory" }], + kind: 4 /* MultiLine */ + }, }; })(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + /** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + */ + ts.directorySeparator = "/"; + var altDirectorySeparator = "\\"; + var urlSchemeSeparator = "://"; + var backslashRegExp = /\\/g; + //// Path Tests + /** + * Determines whether a charCode corresponds to `/` or `\`. + */ + function isAnyDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + } + ts.isAnyDirectorySeparator = isAnyDirectorySeparator; + /** + * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.). + */ + function isUrl(path) { + return getEncodedRootLength(path) < 0; + } + ts.isUrl = isUrl; + /** + * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path + * like `c:`, `c:\` or `c:/`). + */ + function isRootedDiskPath(path) { + return getEncodedRootLength(path) > 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + /** + * Determines whether a path consists only of a path root. + */ + function isDiskPathRoot(path) { + var rootLength = getEncodedRootLength(path); + return rootLength > 0 && rootLength === path.length; + } + ts.isDiskPathRoot = isDiskPathRoot; + /** + * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.). + * + * ```ts + * // POSIX + * pathIsAbsolute("/path/to/file.ext") === true + * // DOS + * pathIsAbsolute("c:/path/to/file.ext") === true + * // URL + * pathIsAbsolute("file:///path/to/file.ext") === true + * // Non-absolute + * pathIsAbsolute("path/to/file.ext") === false + * pathIsAbsolute("./path/to/file.ext") === false + * ``` + */ + function pathIsAbsolute(path) { + return getEncodedRootLength(path) !== 0; + } + ts.pathIsAbsolute = pathIsAbsolute; + /** + * Determines whether a path starts with a relative path component (i.e. `.` or `..`). + */ + function pathIsRelative(path) { + return /^\.\.?($|[\\/])/.test(path); + } + ts.pathIsRelative = pathIsRelative; + /** + * Determines whether a path is neither relative nor absolute, e.g. "path/to/file". + * Also known misleadingly as "non-relative". + */ + function pathIsBareSpecifier(path) { + return !pathIsAbsolute(path) && !pathIsRelative(path); + } + ts.pathIsBareSpecifier = pathIsBareSpecifier; + function hasExtension(fileName) { + return ts.stringContains(getBaseFileName(fileName), "."); + } + ts.hasExtension = hasExtension; + function fileExtensionIs(path, extension) { + return path.length > extension.length && ts.endsWith(path, extension); + } + ts.fileExtensionIs = fileExtensionIs; + function fileExtensionIsOneOf(path, extensions) { + for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { + var extension = extensions_1[_i]; + if (fileExtensionIs(path, extension)) { + return true; + } + } + return false; + } + ts.fileExtensionIsOneOf = fileExtensionIsOneOf; + /** + * Determines whether a path has a trailing separator (`/` or `\\`). + */ + function hasTrailingDirectorySeparator(path) { + return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); + } + ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; + //// Path Parsing + function isVolumeCharacter(charCode) { + return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || + (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + } + function getFileUrlVolumeSeparatorEnd(url, start) { + var ch0 = url.charCodeAt(start); + if (ch0 === 58 /* colon */) + return start + 1; + if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + var ch2 = url.charCodeAt(start + 2); + if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + return start + 3; + } + return -1; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * If the root is part of a URL, the twos-complement of the root length is returned. + */ + function getEncodedRootLength(path) { + if (!path) + return 0; + var ch0 = path.charCodeAt(0); + // POSIX or UNC + if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (path.charCodeAt(1) !== ch0) + return 1; // POSIX: "/" (or non-normalized "\") + var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); + if (p1 < 0) + return path.length; // UNC: "//server" or "\\server" + return p1 + 1; // UNC: "//server/" or "\\server\" + } + // DOS + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + var ch2 = path.charCodeAt(2); + if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + return 3; // DOS: "c:/" or "c:\" + if (path.length === 2) + return 2; // DOS: "c:" (but not "c:d") + } + // URL + var schemeEnd = path.indexOf(urlSchemeSeparator); + if (schemeEnd !== -1) { + var authorityStart = schemeEnd + urlSchemeSeparator.length; + var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); + if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" + // For local "file" URLs, include the leading DOS volume (if present). + // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a + // special case interpreted as "the machine from which the URL is being interpreted". + var scheme = path.slice(0, schemeEnd); + var authority = path.slice(authorityStart, authorityEnd); + if (scheme === "file" && (authority === "" || authority === "localhost") && + isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { + var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); + if (volumeSeparatorEnd !== -1) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" + return ~(volumeSeparatorEnd + 1); + } + if (volumeSeparatorEnd === path.length) { + // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" + // but not "file:///c:d" or "file:///c%3ad" + return ~volumeSeparatorEnd; + } + } + } + return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" + } + return ~path.length; // URL: "file://server", "http://server" + } + // relative + return 0; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * + * For example: + * ```ts + * getRootLength("a") === 0 // "" + * getRootLength("/") === 1 // "/" + * getRootLength("c:") === 2 // "c:" + * getRootLength("c:d") === 0 // "" + * getRootLength("c:/") === 3 // "c:/" + * getRootLength("c:\\") === 3 // "c:\\" + * getRootLength("//server") === 7 // "//server" + * getRootLength("//server/share") === 8 // "//server/" + * getRootLength("\\\\server") === 7 // "\\\\server" + * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" + * getRootLength("file:///path") === 8 // "file:///" + * getRootLength("file:///c:") === 10 // "file:///c:" + * getRootLength("file:///c:d") === 8 // "file:///" + * getRootLength("file:///c:/path") === 11 // "file:///c:/" + * getRootLength("file://server") === 13 // "file://server" + * getRootLength("file://server/path") === 14 // "file://server/" + * getRootLength("http://server") === 13 // "http://server" + * getRootLength("http://server/path") === 14 // "http://server/" + * ``` + */ + function getRootLength(path) { + var rootLength = getEncodedRootLength(path); + return rootLength < 0 ? ~rootLength : rootLength; + } + ts.getRootLength = getRootLength; + function getDirectoryPath(path) { + path = normalizeSlashes(path); + // If the path provided is itself the root, then return it. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return path; + // return the leading portion of the path up to the last (non-terminal) directory separator + // but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function getBaseFileName(path, extensions, ignoreCase) { + path = normalizeSlashes(path); + // if the path provided is itself the root, then it has not file name. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return ""; + // return the trailing portion of the path starting after the last (non-terminal) directory + // separator but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); + var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; + return extension ? name.slice(0, name.length - extension.length) : name; + } + ts.getBaseFileName = getBaseFileName; + function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { + if (!ts.startsWith(extension, ".")) + extension = "." + extension; + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + var pathExtension = path.slice(path.length - extension.length); + if (stringEqualityComparer(pathExtension, extension)) { + return pathExtension; + } + } + } + function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { + if (typeof extensions === "string") { + return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || ""; + } + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer); + if (result) + return result; + } + return ""; + } + function getAnyExtensionFromPath(path, extensions, ignoreCase) { + // Retrieves any string from the final "." onwards from a base file name. + // Unlike extensionFromPath, which throws an exception on unrecognized extensions. + if (extensions) { + return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); + } + var baseFileName = getBaseFileName(path); + var extensionIndex = baseFileName.lastIndexOf("."); + if (extensionIndex >= 0) { + return baseFileName.substring(extensionIndex); + } + return ""; + } + ts.getAnyExtensionFromPath = getAnyExtensionFromPath; + function pathComponents(path, rootLength) { + var root = path.substring(0, rootLength); + var rest = path.substring(rootLength).split(ts.directorySeparator); + if (rest.length && !ts.lastOrUndefined(rest)) + rest.pop(); + return __spreadArrays([root], rest); + } + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is not normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * // POSIX + * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"] + * getPathComponents("/path/to/") === ["/", "path", "to"] + * getPathComponents("/") === ["/"] + * // DOS + * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"] + * getPathComponents("c:/path/to/") === ["c:/", "path", "to"] + * getPathComponents("c:/") === ["c:/"] + * getPathComponents("c:") === ["c:"] + * // URL + * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"] + * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"] + * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"] + * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"] + * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"] + * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"] + * getPathComponents("file://server/") === ["file://server/"] + * getPathComponents("file://server") === ["file://server"] + * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"] + * getPathComponents("file:///path/to/") === ["file:///", "path", "to"] + * getPathComponents("file:///") === ["file:///"] + * getPathComponents("file://") === ["file://"] + */ + function getPathComponents(path, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } + path = combinePaths(currentDirectory, path); + return pathComponents(path, getRootLength(path)); + } + ts.getPathComponents = getPathComponents; + //// Path Formatting + /** + * Formats a parsed path consisting of a root component (at index 0) and zero or more path + * segments (at indices > 0). + * + * ```ts + * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext" + * ``` + */ + function getPathFromPathComponents(pathComponents) { + if (pathComponents.length === 0) + return ""; + var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]); + return root + pathComponents.slice(1).join(ts.directorySeparator); + } + ts.getPathFromPathComponents = getPathFromPathComponents; + //// Path Normalization + /** + * Normalize path separators, converting `\` into `/`. + */ + function normalizeSlashes(path) { + return path.replace(backslashRegExp, ts.directorySeparator); + } + ts.normalizeSlashes = normalizeSlashes; + /** + * Reduce an array of path components to a more simplified path by navigating any + * `"."` or `".."` entries in the path. + */ + function reducePathComponents(components) { + if (!ts.some(components)) + return []; + var reduced = [components[0]]; + for (var i = 1; i < components.length; i++) { + var component = components[i]; + if (!component) + continue; + if (component === ".") + continue; + if (component === "..") { + if (reduced.length > 1) { + if (reduced[reduced.length - 1] !== "..") { + reduced.pop(); + continue; + } + } + else if (reduced[0]) + continue; + } + reduced.push(component); + } + return reduced; + } + ts.reducePathComponents = reducePathComponents; + /** + * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. + * + * ```ts + * // Non-rooted + * combinePaths("path", "to", "file.ext") === "path/to/file.ext" + * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext" + * // POSIX + * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext" + * combinePaths("/path", "/to", "file.ext") === "/to/file.ext" + * // DOS + * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext" + * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext" + * // URL + * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext" + * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext" + * ``` + */ + function combinePaths(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + if (path) + path = normalizeSlashes(path); + for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { + var relativePath = paths_1[_a]; + if (!relativePath) + continue; + relativePath = normalizeSlashes(relativePath); + if (!path || getRootLength(relativePath) !== 0) { + path = relativePath; + } + else { + path = ensureTrailingDirectorySeparator(path) + relativePath; + } + } + return path; + } + ts.combinePaths = combinePaths; + /** + * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any + * `.` and `..` path components are resolved. Trailing directory separators are preserved. + * + * ```ts + * resolvePath("/path", "to", "file.ext") === "path/to/file.ext" + * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/" + * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext" + * ``` + */ + function resolvePath(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path)); + } + ts.resolvePath = resolvePath; + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"] + * ``` + */ + function getNormalizedPathComponents(path, currentDirectory) { + return reducePathComponents(getPathComponents(path, currentDirectory)); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function normalizePath(path) { + path = normalizeSlashes(path); + var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); + return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; + } + ts.normalizePath = normalizePath; + function getPathWithoutRoot(pathComponents) { + if (pathComponents.length === 0) + return ""; + return pathComponents.slice(1).join(ts.directorySeparator); + } + function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { + return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; + function normalizePathAndParts(path) { + path = normalizeSlashes(path); + var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; + } + else { + return { path: root, parts: parts }; + } + } + ts.normalizePathAndParts = normalizePathAndParts; + function removeTrailingDirectorySeparator(path) { + if (hasTrailingDirectorySeparator(path)) { + return path.substr(0, path.length - 1); + } + return path; + } + ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; + function ensureTrailingDirectorySeparator(path) { + if (!hasTrailingDirectorySeparator(path)) { + return path + ts.directorySeparator; + } + return path; + } + ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; + /** + * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed + * with `./` or `../`) so as not to be confused with an unprefixed module name. + * + * ```ts + * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext" + * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext" + * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext" + * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext" + * ``` + */ + function ensurePathIsNonModuleName(path) { + return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path; + } + ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; + function changeAnyExtension(path, ext, extensions, ignoreCase) { + var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); + return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; + } + ts.changeAnyExtension = changeAnyExtension; + //// Path Comparisons + // check path for these segments: '', '.'. '..' + var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + function comparePathsWorker(a, b, componentComparer) { + if (a === b) + return 0 /* EqualTo */; + if (a === undefined) + return -1 /* LessThan */; + if (b === undefined) + return 1 /* GreaterThan */; + // NOTE: Performance optimization - shortcut if the root segments differ as there would be no + // need to perform path reduction. + var aRoot = a.substring(0, getRootLength(a)); + var bRoot = b.substring(0, getRootLength(b)); + var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); + if (result !== 0 /* EqualTo */) { + return result; + } + // NOTE: Performance optimization - shortcut if there are no relative path segments in + // the non-root portion of the path + var aRest = a.substring(aRoot.length); + var bRest = b.substring(bRoot.length); + if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { + return componentComparer(aRest, bRest); + } + // The path contains a relative path segment. Normalize the paths and perform a slower component + // by component comparison. + var aComponents = reducePathComponents(getPathComponents(a)); + var bComponents = reducePathComponents(getPathComponents(b)); + var sharedLength = Math.min(aComponents.length, bComponents.length); + for (var i = 1; i < sharedLength; i++) { + var result_2 = componentComparer(aComponents[i], bComponents[i]); + if (result_2 !== 0 /* EqualTo */) { + return result_2; + } + } + return ts.compareValues(aComponents.length, bComponents.length); + } + /** + * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively. + */ + function comparePathsCaseSensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + } + ts.comparePathsCaseSensitive = comparePathsCaseSensitive; + /** + * Performs a case-insensitive comparison of two paths. + */ + function comparePathsCaseInsensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + } + ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; + function comparePaths(a, b, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + a = combinePaths(currentDirectory, a); + b = combinePaths(currentDirectory, b); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + } + ts.comparePaths = comparePaths; + function containsPath(parent, child, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + parent = combinePaths(currentDirectory, parent); + child = combinePaths(currentDirectory, child); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + if (parent === undefined || child === undefined) + return false; + if (parent === child) + return true; + var parentComponents = reducePathComponents(getPathComponents(parent)); + var childComponents = reducePathComponents(getPathComponents(child)); + if (childComponents.length < parentComponents.length) { + return false; + } + var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; + for (var i = 0; i < parentComponents.length; i++) { + var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; + if (!equalityComparer(parentComponents[i], childComponents[i])) { + return false; + } + } + return true; + } + ts.containsPath = containsPath; + /** + * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. + * Comparison is case-sensitive between the canonical paths. + * + * @deprecated Use `containsPath` if possible. + */ + function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { + var canonicalFileName = getCanonicalFileName(fileName); + var canonicalDirectoryName = getCanonicalFileName(directoryName); + return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); + } + ts.startsWithDirectory = startsWithDirectory; + //// Relative Paths + function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { + var fromComponents = reducePathComponents(getPathComponents(from)); + var toComponents = reducePathComponents(getPathComponents(to)); + var start; + for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { + var fromComponent = getCanonicalFileName(fromComponents[start]); + var toComponent = getCanonicalFileName(toComponents[start]); + var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; + if (!comparer(fromComponent, toComponent)) + break; + } + if (start === 0) { + return toComponents; + } + var components = toComponents.slice(start); + var relative = []; + for (; start < fromComponents.length; start++) { + relative.push(".."); + } + return __spreadArrays([""], relative, components); + } + ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; + function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { + ts.Debug.assert((getRootLength(fromDirectory) > 0) === (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); + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathFromDirectory = getRelativePathFromDirectory; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + } + ts.convertToRelativePath = convertToRelativePath; + function getRelativePathFromFile(from, to, getCanonicalFileName) { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); + } + ts.getRelativePathFromFile = getRelativePathFromFile; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); + var firstComponent = pathComponents[0]; + if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) { + var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; + pathComponents[0] = prefix + firstComponent; + } + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } + ts.forEachAncestorDirectory = forEachAncestorDirectory; + function isNodeModulesDirectory(dirPath) { + return ts.endsWith(dirPath, "/node_modules"); + } + ts.isNodeModulesDirectory = isNodeModulesDirectory; +})(ts || (ts = {})); var ts; (function (ts) { /** @@ -6456,678 +7685,6 @@ var ts; ts.Debug.isDebugging = true; } })(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - /** - * Internally, we represent paths as strings with '/' as the directory separator. - * When we make system calls (eg: LanguageServiceHost.getDirectory()), - * we expect the host to correctly handle paths in our specified format. - */ - ts.directorySeparator = "/"; - var altDirectorySeparator = "\\"; - var urlSchemeSeparator = "://"; - var backslashRegExp = /\\/g; - //// Path Tests - /** - * Determines whether a charCode corresponds to `/` or `\`. - */ - function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; - } - ts.isAnyDirectorySeparator = isAnyDirectorySeparator; - /** - * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.). - */ - function isUrl(path) { - return getEncodedRootLength(path) < 0; - } - ts.isUrl = isUrl; - /** - * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path - * like `c:`, `c:\` or `c:/`). - */ - function isRootedDiskPath(path) { - return getEncodedRootLength(path) > 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - /** - * Determines whether a path consists only of a path root. - */ - function isDiskPathRoot(path) { - var rootLength = getEncodedRootLength(path); - return rootLength > 0 && rootLength === path.length; - } - ts.isDiskPathRoot = isDiskPathRoot; - /** - * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.). - * - * ```ts - * // POSIX - * pathIsAbsolute("/path/to/file.ext") === true - * // DOS - * pathIsAbsolute("c:/path/to/file.ext") === true - * // URL - * pathIsAbsolute("file:///path/to/file.ext") === true - * // Non-absolute - * pathIsAbsolute("path/to/file.ext") === false - * pathIsAbsolute("./path/to/file.ext") === false - * ``` - */ - function pathIsAbsolute(path) { - return getEncodedRootLength(path) !== 0; - } - ts.pathIsAbsolute = pathIsAbsolute; - /** - * Determines whether a path starts with a relative path component (i.e. `.` or `..`). - */ - function pathIsRelative(path) { - return /^\.\.?($|[\\/])/.test(path); - } - ts.pathIsRelative = pathIsRelative; - function hasExtension(fileName) { - return ts.stringContains(getBaseFileName(fileName), "."); - } - ts.hasExtension = hasExtension; - function fileExtensionIs(path, extension) { - return path.length > extension.length && ts.endsWith(path, extension); - } - ts.fileExtensionIs = fileExtensionIs; - function fileExtensionIsOneOf(path, extensions) { - for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { - var extension = extensions_1[_i]; - if (fileExtensionIs(path, extension)) { - return true; - } - } - return false; - } - ts.fileExtensionIsOneOf = fileExtensionIsOneOf; - /** - * Determines whether a path has a trailing separator (`/` or `\\`). - */ - function hasTrailingDirectorySeparator(path) { - return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); - } - ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; - //// Path Parsing - function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); - } - function getFileUrlVolumeSeparatorEnd(url, start) { - var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) - return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { - var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) - return start + 3; - } - return -1; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * If the root is part of a URL, the twos-complement of the root length is returned. - */ - function getEncodedRootLength(path) { - if (!path) - return 0; - var ch0 = path.charCodeAt(0); - // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { - if (path.charCodeAt(1) !== ch0) - return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); - if (p1 < 0) - return path.length; // UNC: "//server" or "\\server" - return p1 + 1; // UNC: "//server/" or "\\server\" - } - // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { - var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) - return 3; // DOS: "c:/" or "c:\" - if (path.length === 2) - return 2; // DOS: "c:" (but not "c:d") - } - // URL - var schemeEnd = path.indexOf(urlSchemeSeparator); - if (schemeEnd !== -1) { - var authorityStart = schemeEnd + urlSchemeSeparator.length; - var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); - if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" - // For local "file" URLs, include the leading DOS volume (if present). - // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a - // special case interpreted as "the machine from which the URL is being interpreted". - var scheme = path.slice(0, schemeEnd); - var authority = path.slice(authorityStart, authorityEnd); - if (scheme === "file" && (authority === "" || authority === "localhost") && - isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { - var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); - if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { - // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" - return ~(volumeSeparatorEnd + 1); - } - if (volumeSeparatorEnd === path.length) { - // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" - // but not "file:///c:d" or "file:///c%3ad" - return ~volumeSeparatorEnd; - } - } - } - return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" - } - return ~path.length; // URL: "file://server", "http://server" - } - // relative - return 0; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * - * For example: - * ```ts - * getRootLength("a") === 0 // "" - * getRootLength("/") === 1 // "/" - * getRootLength("c:") === 2 // "c:" - * getRootLength("c:d") === 0 // "" - * getRootLength("c:/") === 3 // "c:/" - * getRootLength("c:\\") === 3 // "c:\\" - * getRootLength("//server") === 7 // "//server" - * getRootLength("//server/share") === 8 // "//server/" - * getRootLength("\\\\server") === 7 // "\\\\server" - * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" - * getRootLength("file:///path") === 8 // "file:///" - * getRootLength("file:///c:") === 10 // "file:///c:" - * getRootLength("file:///c:d") === 8 // "file:///" - * getRootLength("file:///c:/path") === 11 // "file:///c:/" - * getRootLength("file://server") === 13 // "file://server" - * getRootLength("file://server/path") === 14 // "file://server/" - * getRootLength("http://server") === 13 // "http://server" - * getRootLength("http://server/path") === 14 // "http://server/" - * ``` - */ - function getRootLength(path) { - var rootLength = getEncodedRootLength(path); - return rootLength < 0 ? ~rootLength : rootLength; - } - ts.getRootLength = getRootLength; - function getDirectoryPath(path) { - path = normalizeSlashes(path); - // If the path provided is itself the root, then return it. - var rootLength = getRootLength(path); - if (rootLength === path.length) - return path; - // return the leading portion of the path up to the last (non-terminal) directory separator - // but not including any trailing directory separator. - path = removeTrailingDirectorySeparator(path); - return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function getBaseFileName(path, extensions, ignoreCase) { - path = normalizeSlashes(path); - // if the path provided is itself the root, then it has not file name. - var rootLength = getRootLength(path); - if (rootLength === path.length) - return ""; - // return the trailing portion of the path starting after the last (non-terminal) directory - // separator but not including any trailing directory separator. - path = removeTrailingDirectorySeparator(path); - var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); - var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; - return extension ? name.slice(0, name.length - extension.length) : name; - } - ts.getBaseFileName = getBaseFileName; - function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { - if (!ts.startsWith(extension, ".")) - extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { - var pathExtension = path.slice(path.length - extension.length); - if (stringEqualityComparer(pathExtension, extension)) { - return pathExtension; - } - } - } - function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { - if (typeof extensions === "string") { - return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || ""; - } - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer); - if (result) - return result; - } - return ""; - } - function getAnyExtensionFromPath(path, extensions, ignoreCase) { - // Retrieves any string from the final "." onwards from a base file name. - // Unlike extensionFromPath, which throws an exception on unrecognized extensions. - if (extensions) { - return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); - } - var baseFileName = getBaseFileName(path); - var extensionIndex = baseFileName.lastIndexOf("."); - if (extensionIndex >= 0) { - return baseFileName.substring(extensionIndex); - } - return ""; - } - ts.getAnyExtensionFromPath = getAnyExtensionFromPath; - function pathComponents(path, rootLength) { - var root = path.substring(0, rootLength); - var rest = path.substring(rootLength).split(ts.directorySeparator); - if (rest.length && !ts.lastOrUndefined(rest)) - rest.pop(); - return __spreadArrays([root], rest); - } - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is not normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - * - * ```ts - * // POSIX - * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"] - * getPathComponents("/path/to/") === ["/", "path", "to"] - * getPathComponents("/") === ["/"] - * // DOS - * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"] - * getPathComponents("c:/path/to/") === ["c:/", "path", "to"] - * getPathComponents("c:/") === ["c:/"] - * getPathComponents("c:") === ["c:"] - * // URL - * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"] - * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"] - * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"] - * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"] - * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"] - * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"] - * getPathComponents("file://server/") === ["file://server/"] - * getPathComponents("file://server") === ["file://server"] - * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"] - * getPathComponents("file:///path/to/") === ["file:///", "path", "to"] - * getPathComponents("file:///") === ["file:///"] - * getPathComponents("file://") === ["file://"] - */ - function getPathComponents(path, currentDirectory) { - if (currentDirectory === void 0) { currentDirectory = ""; } - path = combinePaths(currentDirectory, path); - return pathComponents(path, getRootLength(path)); - } - ts.getPathComponents = getPathComponents; - //// Path Formatting - /** - * Formats a parsed path consisting of a root component (at index 0) and zero or more path - * segments (at indices > 0). - * - * ```ts - * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext" - * ``` - */ - function getPathFromPathComponents(pathComponents) { - if (pathComponents.length === 0) - return ""; - var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]); - return root + pathComponents.slice(1).join(ts.directorySeparator); - } - ts.getPathFromPathComponents = getPathFromPathComponents; - //// Path Normalization - /** - * Normalize path separators, converting `\` into `/`. - */ - function normalizeSlashes(path) { - return path.replace(backslashRegExp, ts.directorySeparator); - } - ts.normalizeSlashes = normalizeSlashes; - /** - * Reduce an array of path components to a more simplified path by navigating any - * `"."` or `".."` entries in the path. - */ - function reducePathComponents(components) { - if (!ts.some(components)) - return []; - var reduced = [components[0]]; - for (var i = 1; i < components.length; i++) { - var component = components[i]; - if (!component) - continue; - if (component === ".") - continue; - if (component === "..") { - if (reduced.length > 1) { - if (reduced[reduced.length - 1] !== "..") { - reduced.pop(); - continue; - } - } - else if (reduced[0]) - continue; - } - reduced.push(component); - } - return reduced; - } - ts.reducePathComponents = reducePathComponents; - /** - * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. - * - * ```ts - * // Non-rooted - * combinePaths("path", "to", "file.ext") === "path/to/file.ext" - * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext" - * // POSIX - * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext" - * combinePaths("/path", "/to", "file.ext") === "/to/file.ext" - * // DOS - * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext" - * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext" - * // URL - * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext" - * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext" - * ``` - */ - function combinePaths(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; - } - if (path) - path = normalizeSlashes(path); - for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { - var relativePath = paths_1[_a]; - if (!relativePath) - continue; - relativePath = normalizeSlashes(relativePath); - if (!path || getRootLength(relativePath) !== 0) { - path = relativePath; - } - else { - path = ensureTrailingDirectorySeparator(path) + relativePath; - } - } - return path; - } - ts.combinePaths = combinePaths; - /** - * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any - * `.` and `..` path components are resolved. Trailing directory separators are preserved. - * - * ```ts - * resolvePath("/path", "to", "file.ext") === "path/to/file.ext" - * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/" - * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext" - * ``` - */ - function resolvePath(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; - } - return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path)); - } - ts.resolvePath = resolvePath; - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - * - * ```ts - * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"] - * ``` - */ - function getNormalizedPathComponents(path, currentDirectory) { - return reducePathComponents(getPathComponents(path, currentDirectory)); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - function normalizePath(path) { - path = normalizeSlashes(path); - var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); - return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; - } - ts.normalizePath = normalizePath; - function getPathWithoutRoot(pathComponents) { - if (pathComponents.length === 0) - return ""; - return pathComponents.slice(1).join(ts.directorySeparator); - } - function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { - return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; - function toPath(fileName, basePath, getCanonicalFileName) { - var nonCanonicalizedPath = isRootedDiskPath(fileName) - ? normalizePath(fileName) - : getNormalizedAbsolutePath(fileName, basePath); - return getCanonicalFileName(nonCanonicalizedPath); - } - ts.toPath = toPath; - function normalizePathAndParts(path) { - path = normalizeSlashes(path); - var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); - if (parts.length) { - var joinedParts = root + parts.join(ts.directorySeparator); - return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; - } - else { - return { path: root, parts: parts }; - } - } - ts.normalizePathAndParts = normalizePathAndParts; - function removeTrailingDirectorySeparator(path) { - if (hasTrailingDirectorySeparator(path)) { - return path.substr(0, path.length - 1); - } - return path; - } - ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; - function ensureTrailingDirectorySeparator(path) { - if (!hasTrailingDirectorySeparator(path)) { - return path + ts.directorySeparator; - } - return path; - } - ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; - /** - * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed - * with `./` or `../`) so as not to be confused with an unprefixed module name. - * - * ```ts - * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext" - * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext" - * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext" - * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext" - * ``` - */ - function ensurePathIsNonModuleName(path) { - return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path; - } - ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; - function changeAnyExtension(path, ext, extensions, ignoreCase) { - var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); - return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; - } - ts.changeAnyExtension = changeAnyExtension; - //// Path Comparisons - // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; - function comparePathsWorker(a, b, componentComparer) { - if (a === b) - return 0 /* EqualTo */; - if (a === undefined) - return -1 /* LessThan */; - if (b === undefined) - return 1 /* GreaterThan */; - // NOTE: Performance optimization - shortcut if the root segments differ as there would be no - // need to perform path reduction. - var aRoot = a.substring(0, getRootLength(a)); - var bRoot = b.substring(0, getRootLength(b)); - var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { - return result; - } - // NOTE: Performance optimization - shortcut if there are no relative path segments in - // the non-root portion of the path - var aRest = a.substring(aRoot.length); - var bRest = b.substring(bRoot.length); - if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { - return componentComparer(aRest, bRest); - } - // The path contains a relative path segment. Normalize the paths and perform a slower component - // by component comparison. - var aComponents = reducePathComponents(getPathComponents(a)); - var bComponents = reducePathComponents(getPathComponents(b)); - var sharedLength = Math.min(aComponents.length, bComponents.length); - for (var i = 1; i < sharedLength; i++) { - var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { - return result_2; - } - } - return ts.compareValues(aComponents.length, bComponents.length); - } - /** - * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively. - */ - function comparePathsCaseSensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); - } - ts.comparePathsCaseSensitive = comparePathsCaseSensitive; - /** - * Performs a case-insensitive comparison of two paths. - */ - function comparePathsCaseInsensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); - } - ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; - function comparePaths(a, b, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - a = combinePaths(currentDirectory, a); - b = combinePaths(currentDirectory, b); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; - } - return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); - } - ts.comparePaths = comparePaths; - function containsPath(parent, child, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - parent = combinePaths(currentDirectory, parent); - child = combinePaths(currentDirectory, child); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; - } - if (parent === undefined || child === undefined) - return false; - if (parent === child) - return true; - var parentComponents = reducePathComponents(getPathComponents(parent)); - var childComponents = reducePathComponents(getPathComponents(child)); - if (childComponents.length < parentComponents.length) { - return false; - } - var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; - for (var i = 0; i < parentComponents.length; i++) { - var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; - if (!equalityComparer(parentComponents[i], childComponents[i])) { - return false; - } - } - return true; - } - ts.containsPath = containsPath; - /** - * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. - * Comparison is case-sensitive between the canonical paths. - * - * @deprecated Use `containsPath` if possible. - */ - function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { - var canonicalFileName = getCanonicalFileName(fileName); - var canonicalDirectoryName = getCanonicalFileName(directoryName); - return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); - } - ts.startsWithDirectory = startsWithDirectory; - //// Relative Paths - function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { - var fromComponents = reducePathComponents(getPathComponents(from)); - var toComponents = reducePathComponents(getPathComponents(to)); - var start; - for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { - var fromComponent = getCanonicalFileName(fromComponents[start]); - var toComponent = getCanonicalFileName(toComponents[start]); - var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; - if (!comparer(fromComponent, toComponent)) - break; - } - if (start === 0) { - return toComponents; - } - var components = toComponents.slice(start); - var relative = []; - for (; start < fromComponents.length; start++) { - relative.push(".."); - } - return __spreadArrays([""], relative, components); - } - ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; - function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { - ts.Debug.assert((getRootLength(fromDirectory) > 0) === (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); - return getPathFromPathComponents(pathComponents); - } - ts.getRelativePathFromDirectory = getRelativePathFromDirectory; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - } - ts.convertToRelativePath = convertToRelativePath; - function getRelativePathFromFile(from, to, getCanonicalFileName) { - return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); - } - ts.getRelativePathFromFile = getRelativePathFromFile; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); - var firstComponent = pathComponents[0]; - if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) { - var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; - pathComponents[0] = prefix + firstComponent; - } - return getPathFromPathComponents(pathComponents); - } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - function forEachAncestorDirectory(directory, callback) { - while (true) { - var result = callback(directory); - if (result !== undefined) { - return result; - } - var parentPath = getDirectoryPath(directory); - if (parentPath === directory) { - return undefined; - } - directory = parentPath; - } - } - ts.forEachAncestorDirectory = forEachAncestorDirectory; - function isNodeModulesDirectory(dirPath) { - return ts.endsWith(dirPath, "/node_modules"); - } - ts.isNodeModulesDirectory = isNodeModulesDirectory; -})(ts || (ts = {})); // <auto-generated /> // generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' /* @internal */ @@ -7162,7 +7719,7 @@ var ts; Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), - _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), + _0_modifier_cannot_appear_on_class_elements_of_this_kind: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_class_elements_of_this_kind_1031", "'{0}' modifier cannot appear on class elements of this kind."), super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), @@ -7302,7 +7859,7 @@ var ts; Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type: diag(1205, ts.DiagnosticCategory.Error, "Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type_1205", "Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'."), 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."), - 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."), + _0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module: diag(1208, ts.DiagnosticCategory.Error, "_0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_imp_1208", "'{0}' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module."), 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."), @@ -7350,11 +7907,12 @@ var ts; A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), - Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."), Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module: diag(1262, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module_1262", "Identifier expected. '{0}' is a reserved word at the top-level of a module."), + Declarations_with_initializers_cannot_also_have_definite_assignment_assertions: diag(1263, ts.DiagnosticCategory.Error, "Declarations_with_initializers_cannot_also_have_definite_assignment_assertions_1263", "Declarations with initializers cannot also have definite assignment assertions."), + Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, ts.DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), @@ -7371,7 +7929,7 @@ var ts; Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'."), Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), + Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."), String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), @@ -7387,9 +7945,9 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), - An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), + An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), @@ -7432,6 +7990,7 @@ var ts; Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1386, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386", "Constructor type notation must be parenthesized when used in a union type."), Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."), Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), + _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -7557,6 +8116,7 @@ var ts; Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), + Types_of_construct_signatures_are_incompatible: diag(2419, ts.DiagnosticCategory.Error, "Types_of_construct_signatures_are_incompatible_2419", "Types of construct signatures are incompatible."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -7680,6 +8240,7 @@ var ts; The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), + Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later."), Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"), Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"), Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."), @@ -7703,13 +8264,13 @@ var ts; Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), - Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'"), + Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'."), Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."), Unused_ts_expect_error_directive: diag(2578, ts.DiagnosticCategory.Error, "Unused_ts_expect_error_directive_2578", "Unused '@ts-expect-error' directive."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to '{1}' or later."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), _0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{0}' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."), Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."), @@ -7717,9 +8278,9 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant: diag(2588, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."), Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, ts.DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."), Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, ts.DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_th_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_an_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add `jquery` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."), _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), @@ -7787,6 +8348,7 @@ var ts; All_declarations_of_0_must_have_identical_modifiers: diag(2687, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_modifiers_2687", "All declarations of '{0}' must have identical modifiers."), Cannot_find_type_definition_file_for_0: diag(2688, ts.DiagnosticCategory.Error, "Cannot_find_type_definition_file_for_0_2688", "Cannot find type definition file for '{0}'."), Cannot_extend_an_interface_0_Did_you_mean_implements: diag(2689, ts.DiagnosticCategory.Error, "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", "Cannot extend an interface '{0}'. Did you mean 'implements'?"), + _0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0: diag(2690, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0_2690", "'{0}' only refers to a type, but is being used as a value here. Did you mean to use '{1} in {0}'?"), An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: diag(2691, ts.DiagnosticCategory.Error, "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead."), _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, ts.DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."), _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."), @@ -7820,7 +8382,7 @@ var ts; Cannot_invoke_an_object_which_is_possibly_null: diag(2721, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_2721", "Cannot invoke an object which is possibly 'null'."), Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."), Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."), - Module_0_has_no_exported_member_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_2_2724", "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?"), + _0_has_no_exported_member_named_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "_0_has_no_exported_member_named_1_Did_you_mean_2_2724", "'{0}' has no exported member named '{1}'. Did you mean '{2}'?"), Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), @@ -7828,7 +8390,7 @@ var ts; Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), An_arrow_function_cannot_have_a_this_parameter: diag(2730, ts.DiagnosticCategory.Error, "An_arrow_function_cannot_have_a_this_parameter_2730", "An arrow function cannot have a 'this' parameter."), Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."), - Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension"), + Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension."), Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."), Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"), Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"), @@ -7889,6 +8451,10 @@ var ts; The_operand_of_a_delete_operator_must_be_optional: diag(2790, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_optional_2790", "The operand of a 'delete' operator must be optional."), Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later: diag(2791, ts.DiagnosticCategory.Error, "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791", "Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later."), Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option: diag(2792, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_th_2792", "Cannot find module '{0}'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?"), + The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible: diag(2793, ts.DiagnosticCategory.Error, "The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_2793", "The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible."), + Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise: diag(2794, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794", "Expected {0} arguments, but got {1}. Did you forget to include 'void' in your type argument to 'Promise'?"), + The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types: diag(2795, ts.DiagnosticCategory.Error, "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795", "The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types."), + It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked: diag(2796, ts.DiagnosticCategory.Error, "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796", "It is likely that you are missing a comma to separate these two template expressions. They form a tagged template expression which cannot be invoked."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -8002,7 +8568,6 @@ var ts; Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: diag(5057, ts.DiagnosticCategory.Error, "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057", "Cannot find a tsconfig.json file at the specified directory: '{0}'."), The_specified_path_does_not_exist_Colon_0: diag(5058, ts.DiagnosticCategory.Error, "The_specified_path_does_not_exist_Colon_0_5058", "The specified path does not exist: '{0}'."), Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."), - Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."), Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."), Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."), Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."), @@ -8031,6 +8596,8 @@ var ts; A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."), A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a `...` before the name, rather than before the type."), The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."), + Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."), + Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, ts.DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -8221,7 +8788,7 @@ var ts; 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}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), - All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), + All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused."), package_json_has_a_typesVersions_field_with_version_specific_path_mappings: diag(6206, ts.DiagnosticCategory.Message, "package_json_has_a_typesVersions_field_with_version_specific_path_mappings_6206", "'package.json' has a 'typesVersions' field with version-specific path mappings."), package_json_does_not_have_a_typesVersions_entry_that_matches_version_0: diag(6207, ts.DiagnosticCategory.Message, "package_json_does_not_have_a_typesVersions_entry_that_matches_version_0_6207", "'package.json' does not have a 'typesVersions' entry that matches version '{0}'."), package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2: diag(6208, ts.DiagnosticCategory.Message, "package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_ma_6208", "'package.json' has a 'typesVersions' entry '{0}' that matches compiler version '{1}', looking for a pattern to match module name '{2}'."), @@ -8253,6 +8820,8 @@ var ts; This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without: diag(6234, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234", "This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?"), Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."), Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, ts.DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."), + Generates_an_event_trace_and_a_list_of_types: diag(6237, ts.DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."), + Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the `jsx` and `jsxs` factory functions from. eg, react"), 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"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -8298,11 +8867,13 @@ var ts; Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6384, ts.DiagnosticCategory.Message, "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384", "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it."), _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), + Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -8330,7 +8901,7 @@ var ts; Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: diag(7032, ts.DiagnosticCategory.Error, "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation."), Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: diag(7033, ts.DiagnosticCategory.Error, "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation."), Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: diag(7034, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined."), - Try_npm_install_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: diag(7035, ts.DiagnosticCategory.Error, "Try_npm_install_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035", "Try `npm install @types/{1}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`"), + Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: diag(7035, ts.DiagnosticCategory.Error, "Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare__7035", "Try `npm i --save-dev @types/{1}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`"), Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0: diag(7036, ts.DiagnosticCategory.Error, "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036", "Dynamic import's specifier must be of type 'string', but here has type '{0}'."), Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), @@ -8351,6 +8922,7 @@ var ts; 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}'."), _0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type: diag(7055, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type_7055", "'{0}', which lacks return-type annotation, implicitly has an '{1}' yield type."), + The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed: diag(7056, ts.DiagnosticCategory.Error, "The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_ty_7056", "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."), 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_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."), @@ -8461,6 +9033,7 @@ var ts; Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), + Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"), Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"), Extract_function: diag(95005, ts.DiagnosticCategory.Message, "Extract_function_95005", "Extract function"), Extract_constant: diag(95006, ts.DiagnosticCategory.Message, "Extract_constant_95006", "Extract constant"), @@ -8478,6 +9051,7 @@ var ts; Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"), Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"), Add_definite_assignment_assertion_to_property_0: diag(95020, ts.DiagnosticCategory.Message, "Add_definite_assignment_assertion_to_property_0_95020", "Add definite assignment assertion to property '{0}'"), + Convert_all_type_literals_to_mapped_type: diag(95021, ts.DiagnosticCategory.Message, "Convert_all_type_literals_to_mapped_type_95021", "Convert all type literals to mapped type"), Add_all_missing_members: diag(95022, ts.DiagnosticCategory.Message, "Add_all_missing_members_95022", "Add all missing members"), Infer_all_types_from_usage: diag(95023, ts.DiagnosticCategory.Message, "Infer_all_types_from_usage_95023", "Infer all types from usage"), Delete_all_unused_declarations: diag(95024, ts.DiagnosticCategory.Message, "Delete_all_unused_declarations_95024", "Delete all unused declarations"), @@ -8599,10 +9173,12 @@ var ts; Could_not_find_convertible_access_expression: diag(95140, ts.DiagnosticCategory.Message, "Could_not_find_convertible_access_expression_95140", "Could not find convertible access expression"), Could_not_find_matching_access_expressions: diag(95141, ts.DiagnosticCategory.Message, "Could_not_find_matching_access_expressions_95141", "Could not find matching access expressions"), Can_only_convert_logical_AND_access_chains: diag(95142, ts.DiagnosticCategory.Message, "Can_only_convert_logical_AND_access_chains_95142", "Can only convert logical AND access chains"), + Add_void_to_Promise_resolved_without_a_value: diag(95143, ts.DiagnosticCategory.Message, "Add_void_to_Promise_resolved_without_a_value_95143", "Add 'void' to Promise resolved without a value"), + Add_void_to_all_Promises_resolved_without_a_value: diag(95144, ts.DiagnosticCategory.Message, "Add_void_to_all_Promises_resolved_without_a_value_95144", "Add 'void' to all Promises resolved without a value"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), - Private_identifiers_cannot_be_used_as_parameters: diag(18009, ts.DiagnosticCategory.Error, "Private_identifiers_cannot_be_used_as_parameters_18009", "Private identifiers cannot be used as parameters"), + Private_identifiers_cannot_be_used_as_parameters: diag(18009, ts.DiagnosticCategory.Error, "Private_identifiers_cannot_be_used_as_parameters_18009", "Private identifiers cannot be used as parameters."), An_accessibility_modifier_cannot_be_used_with_a_private_identifier: diag(18010, ts.DiagnosticCategory.Error, "An_accessibility_modifier_cannot_be_used_with_a_private_identifier_18010", "An accessibility modifier cannot be used with a private identifier."), The_operand_of_a_delete_operator_cannot_be_a_private_identifier: diag(18011, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011", "The operand of a 'delete' operator cannot be a private identifier."), constructor_is_a_reserved_word: diag(18012, ts.DiagnosticCategory.Error, "constructor_is_a_reserved_word_18012", "'#constructor' is a reserved word."), @@ -8612,7 +9188,7 @@ var ts; Private_identifiers_are_not_allowed_outside_class_bodies: diag(18016, ts.DiagnosticCategory.Error, "Private_identifiers_are_not_allowed_outside_class_bodies_18016", "Private identifiers are not allowed outside class bodies."), The_shadowing_declaration_of_0_is_defined_here: diag(18017, ts.DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"), The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, ts.DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"), - _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier"), + _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier."), A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."), An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."), An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."), @@ -8646,7 +9222,7 @@ var ts; any: 128 /* AnyKeyword */, as: 126 /* AsKeyword */, asserts: 127 /* AssertsKeyword */, - bigint: 154 /* BigIntKeyword */, + bigint: 155 /* BigIntKeyword */, boolean: 131 /* BooleanKeyword */, break: 80 /* BreakKeyword */, case: 81 /* CaseKeyword */, @@ -8668,7 +9244,7 @@ var ts; _a.false = 94 /* FalseKeyword */, _a.finally = 95 /* FinallyKeyword */, _a.for = 96 /* ForKeyword */, - _a.from = 152 /* FromKeyword */, + _a.from = 153 /* FromKeyword */, _a.function = 97 /* FunctionKeyword */, _a.get = 134 /* GetKeyword */, _a.if = 98 /* IfKeyword */, @@ -8678,39 +9254,40 @@ var ts; _a.infer = 135 /* InferKeyword */, _a.instanceof = 101 /* InstanceOfKeyword */, _a.interface = 117 /* InterfaceKeyword */, - _a.is = 136 /* IsKeyword */, - _a.keyof = 137 /* KeyOfKeyword */, + _a.intrinsic = 136 /* IntrinsicKeyword */, + _a.is = 137 /* IsKeyword */, + _a.keyof = 138 /* KeyOfKeyword */, _a.let = 118 /* LetKeyword */, - _a.module = 138 /* ModuleKeyword */, - _a.namespace = 139 /* NamespaceKeyword */, - _a.never = 140 /* NeverKeyword */, + _a.module = 139 /* ModuleKeyword */, + _a.namespace = 140 /* NamespaceKeyword */, + _a.never = 141 /* NeverKeyword */, _a.new = 102 /* NewKeyword */, _a.null = 103 /* NullKeyword */, - _a.number = 143 /* NumberKeyword */, - _a.object = 144 /* ObjectKeyword */, + _a.number = 144 /* NumberKeyword */, + _a.object = 145 /* ObjectKeyword */, _a.package = 119 /* PackageKeyword */, _a.private = 120 /* PrivateKeyword */, _a.protected = 121 /* ProtectedKeyword */, _a.public = 122 /* PublicKeyword */, - _a.readonly = 141 /* ReadonlyKeyword */, - _a.require = 142 /* RequireKeyword */, - _a.global = 153 /* GlobalKeyword */, + _a.readonly = 142 /* ReadonlyKeyword */, + _a.require = 143 /* RequireKeyword */, + _a.global = 154 /* GlobalKeyword */, _a.return = 104 /* ReturnKeyword */, - _a.set = 145 /* SetKeyword */, + _a.set = 146 /* SetKeyword */, _a.static = 123 /* StaticKeyword */, - _a.string = 146 /* StringKeyword */, + _a.string = 147 /* StringKeyword */, _a.super = 105 /* SuperKeyword */, _a.switch = 106 /* SwitchKeyword */, - _a.symbol = 147 /* SymbolKeyword */, + _a.symbol = 148 /* SymbolKeyword */, _a.this = 107 /* ThisKeyword */, _a.throw = 108 /* ThrowKeyword */, _a.true = 109 /* TrueKeyword */, _a.try = 110 /* TryKeyword */, - _a.type = 148 /* TypeKeyword */, + _a.type = 149 /* TypeKeyword */, _a.typeof = 111 /* TypeOfKeyword */, - _a.undefined = 149 /* UndefinedKeyword */, - _a.unique = 150 /* UniqueKeyword */, - _a.unknown = 151 /* UnknownKeyword */, + _a.undefined = 150 /* UndefinedKeyword */, + _a.unique = 151 /* UniqueKeyword */, + _a.unknown = 152 /* UnknownKeyword */, _a.var = 112 /* VarKeyword */, _a.void = 113 /* VoidKeyword */, _a.while = 114 /* WhileKeyword */, @@ -8718,7 +9295,7 @@ var ts; _a.yield = 124 /* YieldKeyword */, _a.async = 129 /* AsyncKeyword */, _a.await = 130 /* AwaitKeyword */, - _a.of = 155 /* OfKeyword */, + _a.of = 156 /* OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj)); var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, "</": 30 /* LessThanSlashToken */, ">>": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 77 /* CaretEqualsToken */, "||=": 74 /* BarBarEqualsToken */, "&&=": 75 /* AmpersandAmpersandEqualsToken */, "??=": 76 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ }))); @@ -9899,9 +10476,9 @@ var ts; return result; } function getIdentifierToken() { - // Reserved words are between 2 and 11 characters long and start with a lowercase letter + // Reserved words are between 2 and 12 characters long and start with a lowercase letter var len = tokenValue.length; - if (len >= 2 && len <= 11) { + if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 /* a */ && ch <= 122 /* z */) { var keyword = textToKeyword.get(tokenValue); @@ -11104,9 +11681,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 158 /* TypeParameter */) { + if (d && d.kind === 159 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 250 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 253 /* InterfaceDeclaration */) { return current; } } @@ -11114,7 +11691,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 165 /* Constructor */; + return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 166 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -11144,14 +11721,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 246 /* VariableDeclaration */) { + if (node.kind === 249 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 247 /* VariableDeclarationList */) { + if (node && node.kind === 250 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 229 /* VariableStatement */) { + if (node && node.kind === 232 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -11242,6 +11819,20 @@ var ts; return !nodeTest || nodeTest(node) ? node : undefined; } ts.getOriginalNode = getOriginalNode; + function findAncestor(node, callback) { + while (node) { + var result = callback(node); + if (result === "quit") { + return undefined; + } + else if (result) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.findAncestor = findAncestor; /** * Gets a value indicating whether a node originated in the parse tree. * @@ -11307,30 +11898,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 213 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + if (expr.kind === 216 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return expr.name; - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 204 /* ParenthesizedExpression */: { + case 207 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 242 /* LabeledStatement */: { + case 245 /* LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11367,16 +11958,16 @@ var ts; switch (declaration.kind) { case 78 /* Identifier */: return declaration; - case 328 /* JSDocPropertyTag */: - case 322 /* JSDocParameterTag */: { + case 333 /* JSDocPropertyTag */: + case 326 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 156 /* QualifiedName */) { + if (name.kind === 157 /* QualifiedName */) { return name.right; } break; } - case 200 /* CallExpression */: - case 213 /* BinaryExpression */: { + case 203 /* CallExpression */: + case 216 /* BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: @@ -11392,15 +11983,15 @@ var ts; return undefined; } } - case 327 /* JSDocTypedefTag */: + case 331 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 321 /* JSDocEnumTag */: + case 325 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 263 /* ExportAssignment */: { + case 266 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -11695,7 +12286,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 307 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 311 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -11727,7 +12318,7 @@ var ts; ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 167 /* SetAccessor */ || node.kind === 166 /* GetAccessor */; + return node.kind === 168 /* SetAccessor */ || node.kind === 167 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -11745,10 +12336,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32 /* OptionalChain */) && - (kind === 198 /* PropertyAccessExpression */ - || kind === 199 /* ElementAccessExpression */ - || kind === 200 /* CallExpression */ - || kind === 222 /* NonNullExpression */); + (kind === 201 /* PropertyAccessExpression */ + || kind === 202 /* ElementAccessExpression */ + || kind === 203 /* CallExpression */ + || kind === 225 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -11783,7 +12374,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 213 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -11800,17 +12391,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 238 /* BreakStatement */ || node.kind === 237 /* ContinueStatement */; + return node.kind === 241 /* BreakStatement */ || node.kind === 240 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 266 /* NamespaceExport */ || node.kind === 265 /* NamedExports */; + return node.kind === 269 /* NamespaceExport */ || node.kind === 268 /* NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 291 /* UnparsedText */: - case 292 /* UnparsedInternalText */: + case 294 /* UnparsedText */: + case 295 /* UnparsedInternalText */: return true; default: return false; @@ -11819,12 +12410,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 289 /* UnparsedPrologue */ || - node.kind === 293 /* UnparsedSyntheticReference */; + node.kind === 292 /* UnparsedPrologue */ || + node.kind === 296 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 328 /* JSDocPropertyTag */ || node.kind === 322 /* JSDocParameterTag */; + return node.kind === 333 /* JSDocPropertyTag */ || node.kind === 326 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -11840,7 +12431,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 156 /* FirstNode */; + return kind >= 157 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -11849,7 +12440,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 155 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 156 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -11890,12 +12481,12 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 262 /* ImportSpecifier */: - case 267 /* ExportSpecifier */: + case 265 /* ImportSpecifier */: + case 270 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: return node.parent.isTypeOnly; - case 259 /* ImportClause */: + case 262 /* ImportClause */: return node.isTypeOnly; default: return false; @@ -11936,7 +12527,7 @@ var ts; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: - case 141 /* ReadonlyKeyword */: + case 142 /* ReadonlyKeyword */: case 123 /* StaticKeyword */: return true; } @@ -11959,7 +12550,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 156 /* QualifiedName */ + return kind === 157 /* QualifiedName */ || kind === 78 /* Identifier */; } ts.isEntityName = isEntityName; @@ -11969,14 +12560,14 @@ var ts; || kind === 79 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 157 /* ComputedPropertyName */; + || kind === 158 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 78 /* Identifier */ - || kind === 193 /* ObjectBindingPattern */ - || kind === 194 /* ArrayBindingPattern */; + || kind === 196 /* ObjectBindingPattern */ + || kind === 197 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -11991,13 +12582,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 248 /* FunctionDeclaration */: - case 164 /* MethodDeclaration */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 251 /* FunctionDeclaration */: + case 165 /* MethodDeclaration */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return true; default: return false; @@ -12006,14 +12597,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 163 /* MethodSignature */: - case 168 /* CallSignature */: - case 309 /* JSDocSignature */: - case 169 /* ConstructSignature */: - case 170 /* IndexSignature */: - case 173 /* FunctionType */: - case 304 /* JSDocFunctionType */: - case 174 /* ConstructorType */: + case 164 /* MethodSignature */: + case 169 /* CallSignature */: + case 313 /* JSDocSignature */: + case 170 /* ConstructSignature */: + case 171 /* IndexSignature */: + case 174 /* FunctionType */: + case 308 /* JSDocFunctionType */: + case 175 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -12028,29 +12619,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 165 /* Constructor */ - || kind === 162 /* PropertyDeclaration */ - || kind === 164 /* MethodDeclaration */ - || kind === 166 /* GetAccessor */ - || kind === 167 /* SetAccessor */ - || kind === 170 /* IndexSignature */ - || kind === 226 /* SemicolonClassElement */; + return kind === 166 /* Constructor */ + || kind === 163 /* PropertyDeclaration */ + || kind === 165 /* MethodDeclaration */ + || kind === 167 /* GetAccessor */ + || kind === 168 /* SetAccessor */ + || kind === 171 /* IndexSignature */ + || kind === 229 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 249 /* ClassDeclaration */ || node.kind === 218 /* ClassExpression */); + return node && (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 166 /* GetAccessor */ || node.kind === 167 /* SetAccessor */); + return node && (node.kind === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return true; default: return false; @@ -12060,11 +12651,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 169 /* ConstructSignature */ - || kind === 168 /* CallSignature */ - || kind === 161 /* PropertySignature */ - || kind === 163 /* MethodSignature */ - || kind === 170 /* IndexSignature */; + return kind === 170 /* ConstructSignature */ + || kind === 169 /* CallSignature */ + || kind === 162 /* PropertySignature */ + || kind === 164 /* MethodSignature */ + || kind === 171 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -12073,12 +12664,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 285 /* PropertyAssignment */ - || kind === 286 /* ShorthandPropertyAssignment */ - || kind === 287 /* SpreadAssignment */ - || kind === 164 /* MethodDeclaration */ - || kind === 166 /* GetAccessor */ - || kind === 167 /* SetAccessor */; + return kind === 288 /* PropertyAssignment */ + || kind === 289 /* ShorthandPropertyAssignment */ + || kind === 290 /* SpreadAssignment */ + || kind === 165 /* MethodDeclaration */ + || kind === 167 /* GetAccessor */ + || kind === 168 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -12093,8 +12684,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 173 /* FunctionType */: - case 174 /* ConstructorType */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: return true; } return false; @@ -12105,8 +12696,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 194 /* ArrayBindingPattern */ - || kind === 193 /* ObjectBindingPattern */; + return kind === 197 /* ArrayBindingPattern */ + || kind === 196 /* ObjectBindingPattern */; } return false; } @@ -12114,15 +12705,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 196 /* ArrayLiteralExpression */ - || kind === 197 /* ObjectLiteralExpression */; + return kind === 199 /* ArrayLiteralExpression */ + || kind === 200 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 195 /* BindingElement */ - || kind === 219 /* OmittedExpression */; + return kind === 198 /* BindingElement */ + || kind === 222 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -12131,9 +12722,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 246 /* VariableDeclaration */: - case 159 /* Parameter */: - case 195 /* BindingElement */: + case 249 /* VariableDeclaration */: + case 160 /* Parameter */: + case 198 /* BindingElement */: return true; } return false; @@ -12154,8 +12745,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 193 /* ObjectBindingPattern */: - case 197 /* ObjectLiteralExpression */: + case 196 /* ObjectBindingPattern */: + case 200 /* ObjectLiteralExpression */: return true; } return false; @@ -12167,8 +12758,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 194 /* ArrayBindingPattern */: - case 196 /* ArrayLiteralExpression */: + case 197 /* ArrayBindingPattern */: + case 199 /* ArrayLiteralExpression */: return true; } return false; @@ -12177,26 +12768,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 198 /* PropertyAccessExpression */ - || kind === 156 /* QualifiedName */ - || kind === 192 /* ImportType */; + return kind === 201 /* PropertyAccessExpression */ + || kind === 157 /* QualifiedName */ + || kind === 195 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 198 /* PropertyAccessExpression */ - || kind === 156 /* QualifiedName */; + return kind === 201 /* PropertyAccessExpression */ + || kind === 157 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 272 /* JsxOpeningElement */: - case 271 /* JsxSelfClosingElement */: - case 200 /* CallExpression */: - case 201 /* NewExpression */: - case 202 /* TaggedTemplateExpression */: - case 160 /* Decorator */: + case 275 /* JsxOpeningElement */: + case 274 /* JsxSelfClosingElement */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: + case 205 /* TaggedTemplateExpression */: + case 161 /* Decorator */: return true; default: return false; @@ -12204,12 +12795,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 200 /* CallExpression */ || node.kind === 201 /* NewExpression */; + return node.kind === 203 /* CallExpression */ || node.kind === 204 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 215 /* TemplateExpression */ + return kind === 218 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -12220,33 +12811,33 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: - case 201 /* NewExpression */: - case 200 /* CallExpression */: - case 270 /* JsxElement */: - case 271 /* JsxSelfClosingElement */: - case 274 /* JsxFragment */: - case 202 /* TaggedTemplateExpression */: - case 196 /* ArrayLiteralExpression */: - case 204 /* ParenthesizedExpression */: - case 197 /* ObjectLiteralExpression */: - case 218 /* ClassExpression */: - case 205 /* FunctionExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: + case 204 /* NewExpression */: + case 203 /* CallExpression */: + case 273 /* JsxElement */: + case 274 /* JsxSelfClosingElement */: + case 277 /* JsxFragment */: + case 205 /* TaggedTemplateExpression */: + case 199 /* ArrayLiteralExpression */: + case 207 /* ParenthesizedExpression */: + case 200 /* ObjectLiteralExpression */: + case 221 /* ClassExpression */: + case 208 /* FunctionExpression */: case 78 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 215 /* TemplateExpression */: + case 218 /* TemplateExpression */: case 94 /* FalseKeyword */: case 103 /* NullKeyword */: case 107 /* ThisKeyword */: case 109 /* TrueKeyword */: case 105 /* SuperKeyword */: - case 222 /* NonNullExpression */: - case 223 /* MetaProperty */: + case 225 /* NonNullExpression */: + case 226 /* MetaProperty */: case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -12260,13 +12851,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 211 /* PrefixUnaryExpression */: - case 212 /* PostfixUnaryExpression */: - case 207 /* DeleteExpression */: - case 208 /* TypeOfExpression */: - case 209 /* VoidExpression */: - case 210 /* AwaitExpression */: - case 203 /* TypeAssertionExpression */: + case 214 /* PrefixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: + case 210 /* DeleteExpression */: + case 211 /* TypeOfExpression */: + case 212 /* VoidExpression */: + case 213 /* AwaitExpression */: + case 206 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -12275,9 +12866,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: return true; - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; default: @@ -12296,15 +12887,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 214 /* ConditionalExpression */: - case 216 /* YieldExpression */: - case 206 /* ArrowFunction */: - case 213 /* BinaryExpression */: - case 217 /* SpreadElement */: - case 221 /* AsExpression */: - case 219 /* OmittedExpression */: - case 332 /* CommaListExpression */: - case 331 /* PartiallyEmittedExpression */: + case 217 /* ConditionalExpression */: + case 219 /* YieldExpression */: + case 209 /* ArrowFunction */: + case 216 /* BinaryExpression */: + case 220 /* SpreadElement */: + case 224 /* AsExpression */: + case 222 /* OmittedExpression */: + case 337 /* CommaListExpression */: + case 336 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -12312,8 +12903,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 203 /* TypeAssertionExpression */ - || kind === 221 /* AsExpression */; + return kind === 206 /* TypeAssertionExpression */ + || kind === 224 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -12324,13 +12915,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 232 /* DoStatement */: - case 233 /* WhileStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: return true; - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -12359,7 +12950,7 @@ var ts; ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 235 /* ForInStatement */ || node.kind === 236 /* ForOfStatement */; + return node.kind === 238 /* ForInStatement */ || node.kind === 239 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -12383,114 +12974,114 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 254 /* ModuleBlock */ - || kind === 253 /* ModuleDeclaration */ + return kind === 257 /* ModuleBlock */ + || kind === 256 /* ModuleDeclaration */ || kind === 78 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 254 /* ModuleBlock */ - || kind === 253 /* ModuleDeclaration */; + return kind === 257 /* ModuleBlock */ + || kind === 256 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 78 /* Identifier */ - || kind === 253 /* ModuleDeclaration */; + || kind === 256 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 261 /* NamedImports */ - || kind === 260 /* NamespaceImport */; + return kind === 264 /* NamedImports */ + || kind === 263 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 253 /* ModuleDeclaration */ || node.kind === 252 /* EnumDeclaration */; + return node.kind === 256 /* ModuleDeclaration */ || node.kind === 255 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 206 /* ArrowFunction */ - || kind === 195 /* BindingElement */ - || kind === 249 /* ClassDeclaration */ - || kind === 218 /* ClassExpression */ - || kind === 165 /* Constructor */ - || kind === 252 /* EnumDeclaration */ - || kind === 288 /* EnumMember */ - || kind === 267 /* ExportSpecifier */ - || kind === 248 /* FunctionDeclaration */ - || kind === 205 /* FunctionExpression */ - || kind === 166 /* GetAccessor */ - || kind === 259 /* ImportClause */ - || kind === 257 /* ImportEqualsDeclaration */ - || kind === 262 /* ImportSpecifier */ - || kind === 250 /* InterfaceDeclaration */ - || kind === 277 /* JsxAttribute */ - || kind === 164 /* MethodDeclaration */ - || kind === 163 /* MethodSignature */ - || kind === 253 /* ModuleDeclaration */ - || kind === 256 /* NamespaceExportDeclaration */ - || kind === 260 /* NamespaceImport */ - || kind === 266 /* NamespaceExport */ - || kind === 159 /* Parameter */ - || kind === 285 /* PropertyAssignment */ - || kind === 162 /* PropertyDeclaration */ - || kind === 161 /* PropertySignature */ - || kind === 167 /* SetAccessor */ - || kind === 286 /* ShorthandPropertyAssignment */ - || kind === 251 /* TypeAliasDeclaration */ - || kind === 158 /* TypeParameter */ - || kind === 246 /* VariableDeclaration */ - || kind === 327 /* JSDocTypedefTag */ - || kind === 320 /* JSDocCallbackTag */ - || kind === 328 /* JSDocPropertyTag */; + return kind === 209 /* ArrowFunction */ + || kind === 198 /* BindingElement */ + || kind === 252 /* ClassDeclaration */ + || kind === 221 /* ClassExpression */ + || kind === 166 /* Constructor */ + || kind === 255 /* EnumDeclaration */ + || kind === 291 /* EnumMember */ + || kind === 270 /* ExportSpecifier */ + || kind === 251 /* FunctionDeclaration */ + || kind === 208 /* FunctionExpression */ + || kind === 167 /* GetAccessor */ + || kind === 262 /* ImportClause */ + || kind === 260 /* ImportEqualsDeclaration */ + || kind === 265 /* ImportSpecifier */ + || kind === 253 /* InterfaceDeclaration */ + || kind === 280 /* JsxAttribute */ + || kind === 165 /* MethodDeclaration */ + || kind === 164 /* MethodSignature */ + || kind === 256 /* ModuleDeclaration */ + || kind === 259 /* NamespaceExportDeclaration */ + || kind === 263 /* NamespaceImport */ + || kind === 269 /* NamespaceExport */ + || kind === 160 /* Parameter */ + || kind === 288 /* PropertyAssignment */ + || kind === 163 /* PropertyDeclaration */ + || kind === 162 /* PropertySignature */ + || kind === 168 /* SetAccessor */ + || kind === 289 /* ShorthandPropertyAssignment */ + || kind === 254 /* TypeAliasDeclaration */ + || kind === 159 /* TypeParameter */ + || kind === 249 /* VariableDeclaration */ + || kind === 331 /* JSDocTypedefTag */ + || kind === 324 /* JSDocCallbackTag */ + || kind === 333 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 248 /* FunctionDeclaration */ - || kind === 268 /* MissingDeclaration */ - || kind === 249 /* ClassDeclaration */ - || kind === 250 /* InterfaceDeclaration */ - || kind === 251 /* TypeAliasDeclaration */ - || kind === 252 /* EnumDeclaration */ - || kind === 253 /* ModuleDeclaration */ - || kind === 258 /* ImportDeclaration */ - || kind === 257 /* ImportEqualsDeclaration */ - || kind === 264 /* ExportDeclaration */ - || kind === 263 /* ExportAssignment */ - || kind === 256 /* NamespaceExportDeclaration */; + return kind === 251 /* FunctionDeclaration */ + || kind === 271 /* MissingDeclaration */ + || kind === 252 /* ClassDeclaration */ + || kind === 253 /* InterfaceDeclaration */ + || kind === 254 /* TypeAliasDeclaration */ + || kind === 255 /* EnumDeclaration */ + || kind === 256 /* ModuleDeclaration */ + || kind === 261 /* ImportDeclaration */ + || kind === 260 /* ImportEqualsDeclaration */ + || kind === 267 /* ExportDeclaration */ + || kind === 266 /* ExportAssignment */ + || kind === 259 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 238 /* BreakStatement */ - || kind === 237 /* ContinueStatement */ - || kind === 245 /* DebuggerStatement */ - || kind === 232 /* DoStatement */ - || kind === 230 /* ExpressionStatement */ - || kind === 228 /* EmptyStatement */ - || kind === 235 /* ForInStatement */ - || kind === 236 /* ForOfStatement */ - || kind === 234 /* ForStatement */ - || kind === 231 /* IfStatement */ - || kind === 242 /* LabeledStatement */ - || kind === 239 /* ReturnStatement */ - || kind === 241 /* SwitchStatement */ - || kind === 243 /* ThrowStatement */ - || kind === 244 /* TryStatement */ - || kind === 229 /* VariableStatement */ - || kind === 233 /* WhileStatement */ - || kind === 240 /* WithStatement */ - || kind === 330 /* NotEmittedStatement */ - || kind === 334 /* EndOfDeclarationMarker */ - || kind === 333 /* MergeDeclarationMarker */; + return kind === 241 /* BreakStatement */ + || kind === 240 /* ContinueStatement */ + || kind === 248 /* DebuggerStatement */ + || kind === 235 /* DoStatement */ + || kind === 233 /* ExpressionStatement */ + || kind === 231 /* EmptyStatement */ + || kind === 238 /* ForInStatement */ + || kind === 239 /* ForOfStatement */ + || kind === 237 /* ForStatement */ + || kind === 234 /* IfStatement */ + || kind === 245 /* LabeledStatement */ + || kind === 242 /* ReturnStatement */ + || kind === 244 /* SwitchStatement */ + || kind === 246 /* ThrowStatement */ + || kind === 247 /* TryStatement */ + || kind === 232 /* VariableStatement */ + || kind === 236 /* WhileStatement */ + || kind === 243 /* WithStatement */ + || kind === 335 /* NotEmittedStatement */ + || kind === 339 /* EndOfDeclarationMarker */ + || kind === 338 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 158 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 326 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 159 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 330 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -12517,10 +13108,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 227 /* Block */) + if (node.kind !== 230 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 244 /* TryStatement */ || node.parent.kind === 284 /* CatchClause */) { + if (node.parent.kind === 247 /* TryStatement */ || node.parent.kind === 287 /* CatchClause */) { return false; } } @@ -12534,15 +13125,15 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 227 /* Block */; + || kind === 230 /* Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 269 /* ExternalModuleReference */ - || kind === 156 /* QualifiedName */ + return kind === 272 /* ExternalModuleReference */ + || kind === 157 /* QualifiedName */ || kind === 78 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -12552,70 +13143,70 @@ var ts; var kind = node.kind; return kind === 107 /* ThisKeyword */ || kind === 78 /* Identifier */ - || kind === 198 /* PropertyAccessExpression */; + || kind === 201 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 270 /* JsxElement */ - || kind === 280 /* JsxExpression */ - || kind === 271 /* JsxSelfClosingElement */ + return kind === 273 /* JsxElement */ + || kind === 283 /* JsxExpression */ + || kind === 274 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 274 /* JsxFragment */; + || kind === 277 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 277 /* JsxAttribute */ - || kind === 279 /* JsxSpreadAttribute */; + return kind === 280 /* JsxAttribute */ + || kind === 282 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 280 /* JsxExpression */; + || kind === 283 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 272 /* JsxOpeningElement */ - || kind === 271 /* JsxSelfClosingElement */; + return kind === 275 /* JsxOpeningElement */ + || kind === 274 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 281 /* CaseClause */ - || kind === 282 /* DefaultClause */; + return kind === 284 /* CaseClause */ + || kind === 285 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 298 /* FirstJSDocNode */ && node.kind <= 328 /* LastJSDocNode */; + return node.kind >= 301 /* FirstJSDocNode */ && node.kind <= 333 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 307 /* JSDocComment */ || node.kind === 306 /* JSDocNamepathType */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 311 /* JSDocComment */ || node.kind === 310 /* JSDocNamepathType */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 310 /* FirstJSDocTagNode */ && node.kind <= 328 /* LastJSDocTagNode */; + return node.kind >= 314 /* FirstJSDocTagNode */ && node.kind <= 333 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 167 /* SetAccessor */; + return node.kind === 168 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 166 /* GetAccessor */; + return node.kind === 167 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -12641,13 +13232,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 246 /* VariableDeclaration */: - case 159 /* Parameter */: - case 195 /* BindingElement */: - case 161 /* PropertySignature */: - case 162 /* PropertyDeclaration */: - case 285 /* PropertyAssignment */: - case 288 /* EnumMember */: + case 249 /* VariableDeclaration */: + case 160 /* Parameter */: + case 198 /* BindingElement */: + case 162 /* PropertySignature */: + case 163 /* PropertyDeclaration */: + case 288 /* PropertyAssignment */: + case 291 /* EnumMember */: return true; default: return false; @@ -12655,12 +13246,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 277 /* JsxAttribute */ || node.kind === 279 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 280 /* JsxAttribute */ || node.kind === 282 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 172 /* TypeReference */ || node.kind === 220 /* ExpressionWithTypeArguments */; + return node.kind === 173 /* TypeReference */ || node.kind === 223 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -12793,20 +13384,6 @@ var ts; }); } ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; - function findAncestor(node, callback) { - while (node) { - var result = callback(node); - if (result === "quit") { - return undefined; - } - else if (result) { - return node; - } - node = node.parent; - } - return undefined; - } - ts.findAncestor = findAncestor; function forEachAncestor(node, callback) { while (true) { var res = callback(node); @@ -12955,7 +13532,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 294 /* SourceFile */) { + while (node && node.kind !== 297 /* SourceFile */) { node = node.parent; } return node; @@ -12963,11 +13540,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 227 /* Block */: - case 255 /* CaseBlock */: - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: + case 230 /* Block */: + case 258 /* CaseBlock */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: return true; } return false; @@ -13163,7 +13740,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 329 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 334 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -13182,8 +13759,12 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return !!findAncestor(node, ts.isJSDocTypeExpression); + return !!ts.findAncestor(node, ts.isJSDocTypeExpression); } + function isExportNamespaceAsDefaultDeclaration(node) { + return !!(ts.isExportDeclaration(node) && node.exportClause && ts.isNamespaceExport(node.exportClause) && node.exportClause.name.escapedText === "default"); + } + ts.isExportNamespaceAsDefaultDeclaration = isExportNamespaceAsDefaultDeclaration; function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } if (nodeIsMissing(node)) { @@ -13221,10 +13802,85 @@ var ts; return emitNode && emitNode.flags || 0; } ts.getEmitFlags = getEmitFlags; - function getLiteralText(node, sourceFile, neverAsciiEscape, jsxAttributeEscape) { + ; + function getScriptTargetFeatures() { + return { + es2015: { + Array: ["find", "findIndex", "fill", "copyWithin", "entries", "keys", "values"], + RegExp: ["flags", "sticky", "unicode"], + Reflect: ["apply", "construct", "defineProperty", "deleteProperty", "get", " getOwnPropertyDescriptor", "getPrototypeOf", "has", "isExtensible", "ownKeys", "preventExtensions", "set", "setPrototypeOf"], + ArrayConstructor: ["from", "of"], + ObjectConstructor: ["assign", "getOwnPropertySymbols", "keys", "is", "setPrototypeOf"], + NumberConstructor: ["isFinite", "isInteger", "isNaN", "isSafeInteger", "parseFloat", "parseInt"], + Math: ["clz32", "imul", "sign", "log10", "log2", "log1p", "expm1", "cosh", "sinh", "tanh", "acosh", "asinh", "atanh", "hypot", "trunc", "fround", "cbrt"], + Map: ["entries", "keys", "values"], + Set: ["entries", "keys", "values"], + Promise: ts.emptyArray, + PromiseConstructor: ["all", "race", "reject", "resolve"], + Symbol: ["for", "keyFor"], + WeakMap: ["entries", "keys", "values"], + WeakSet: ["entries", "keys", "values"], + Iterator: ts.emptyArray, + AsyncIterator: ts.emptyArray, + String: ["codePointAt", "includes", "endsWith", "normalize", "repeat", "startsWith", "anchor", "big", "blink", "bold", "fixed", "fontcolor", "fontsize", "italics", "link", "small", "strike", "sub", "sup"], + StringConstructor: ["fromCodePoint", "raw"] + }, + es2016: { + Array: ["includes"] + }, + es2017: { + Atomics: ts.emptyArray, + SharedArrayBuffer: ts.emptyArray, + String: ["padStart", "padEnd"], + ObjectConstructor: ["values", "entries", "getOwnPropertyDescriptors"], + DateTimeFormat: ["formatToParts"] + }, + es2018: { + Promise: ["finally"], + RegExpMatchArray: ["groups"], + RegExpExecArray: ["groups"], + RegExp: ["dotAll"], + Intl: ["PluralRules"], + AsyncIterable: ts.emptyArray, + AsyncIterableIterator: ts.emptyArray, + AsyncGenerator: ts.emptyArray, + AsyncGeneratorFunction: ts.emptyArray, + }, + es2019: { + Array: ["flat", "flatMap"], + ObjectConstructor: ["fromEntries"], + String: ["trimStart", "trimEnd", "trimLeft", "trimRight"], + Symbol: ["description"] + }, + es2020: { + BigInt: ts.emptyArray, + BigInt64Array: ts.emptyArray, + BigUint64Array: ts.emptyArray, + PromiseConstructor: ["allSettled"], + SymbolConstructor: ["matchAll"], + String: ["matchAll"], + DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"], + RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"] + }, + esnext: { + PromiseConstructor: ["any"], + String: ["replaceAll"], + NumberFormat: ["formatToParts"] + } + }; + } + ts.getScriptTargetFeatures = getScriptTargetFeatures; + var GetLiteralTextFlags; + (function (GetLiteralTextFlags) { + GetLiteralTextFlags[GetLiteralTextFlags["None"] = 0] = "None"; + GetLiteralTextFlags[GetLiteralTextFlags["NeverAsciiEscape"] = 1] = "NeverAsciiEscape"; + GetLiteralTextFlags[GetLiteralTextFlags["JsxAttributeEscape"] = 2] = "JsxAttributeEscape"; + GetLiteralTextFlags[GetLiteralTextFlags["TerminateUnterminatedLiterals"] = 4] = "TerminateUnterminatedLiterals"; + })(GetLiteralTextFlags = ts.GetLiteralTextFlags || (ts.GetLiteralTextFlags = {})); + function getLiteralText(node, sourceFile, flags) { // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. - if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) || + if (!nodeIsSynthesized(node) && node.parent && !(flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) || ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } @@ -13232,8 +13888,8 @@ var ts; // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { case 10 /* StringLiteral */: { - var escapeText = jsxAttributeEscape ? escapeJsxAttributeString : - neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; @@ -13248,7 +13904,7 @@ var ts; case 17 /* TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); switch (node.kind) { @@ -13265,7 +13921,11 @@ var ts; } case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: + return node.text; case 13 /* RegularExpressionLiteral */: + if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + } return node.text; } return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -13288,7 +13948,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 246 /* VariableDeclaration */ && node.parent.kind === 284 /* CatchClause */; + return node.kind === 249 /* VariableDeclaration */ && node.parent.kind === 287 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -13320,11 +13980,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 253 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 256 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 294 /* SourceFile */ || - node.kind === 253 /* ModuleDeclaration */ || + return node.kind === 297 /* SourceFile */ || + node.kind === 256 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -13341,9 +14001,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 294 /* SourceFile */: + case 297 /* SourceFile */: return ts.isExternalModule(node.parent); - case 254 /* ModuleBlock */: + case 257 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -13396,22 +14056,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 294 /* SourceFile */: - case 255 /* CaseBlock */: - case 284 /* CatchClause */: - case 253 /* ModuleDeclaration */: - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 165 /* Constructor */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 297 /* SourceFile */: + case 258 /* CaseBlock */: + case 287 /* CatchClause */: + case 256 /* ModuleDeclaration */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 166 /* Constructor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return true; - case 227 /* Block */: + case 230 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -13421,9 +14081,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 320 /* JSDocCallbackTag */: - case 327 /* JSDocTypedefTag */: - case 309 /* JSDocSignature */: + case 324 /* JSDocCallbackTag */: + case 331 /* JSDocTypedefTag */: + case 313 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -13433,25 +14093,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 163 /* MethodSignature */: - case 170 /* IndexSignature */: - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 304 /* JSDocFunctionType */: - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 326 /* JSDocTemplateTag */: - case 248 /* FunctionDeclaration */: - case 164 /* MethodDeclaration */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 164 /* MethodSignature */: + case 171 /* IndexSignature */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 308 /* JSDocFunctionType */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 330 /* JSDocTemplateTag */: + case 251 /* FunctionDeclaration */: + case 165 /* MethodDeclaration */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -13461,8 +14121,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: - case 257 /* ImportEqualsDeclaration */: + case 261 /* ImportDeclaration */: + case 260 /* ImportEqualsDeclaration */: return true; default: return false; @@ -13471,15 +14131,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: - case 257 /* ImportEqualsDeclaration */: - case 229 /* VariableStatement */: - case 249 /* ClassDeclaration */: - case 248 /* FunctionDeclaration */: - case 253 /* ModuleDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: + case 261 /* ImportDeclaration */: + case 260 /* ImportEqualsDeclaration */: + case 232 /* VariableStatement */: + case 252 /* ClassDeclaration */: + case 251 /* FunctionDeclaration */: + case 256 /* ModuleDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: return true; default: return false; @@ -13493,7 +14153,7 @@ var ts; // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. function getEnclosingBlockScopeContainer(node) { - return findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); }); + return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); }); } ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; // Return display name of an identifier @@ -13508,7 +14168,7 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 157 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 158 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { @@ -13520,7 +14180,7 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -13536,9 +14196,9 @@ var ts; case 79 /* PrivateIdentifier */: case 78 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } @@ -13579,6 +14239,18 @@ var ts; }; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) { + return { + file: sourceFile, + start: 0, + length: 0, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText, + relatedInformation: relatedInformation + }; + } + ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain; function createDiagnosticForRange(sourceFile, range, message) { return { file: sourceFile, @@ -13599,7 +14271,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 227 /* Block */) { + if (node.body && node.body.kind === 230 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -13613,7 +14285,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 294 /* SourceFile */: + case 297 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -13622,28 +14294,28 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 246 /* VariableDeclaration */: - case 195 /* BindingElement */: - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 253 /* ModuleDeclaration */: - case 252 /* EnumDeclaration */: - case 288 /* EnumMember */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 251 /* TypeAliasDeclaration */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 249 /* VariableDeclaration */: + case 198 /* BindingElement */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 256 /* ModuleDeclaration */: + case 255 /* EnumDeclaration */: + case 291 /* EnumMember */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 254 /* TypeAliasDeclaration */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: errorNode = node.name; break; - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 281 /* CaseClause */: - case 282 /* DefaultClause */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -13695,11 +14367,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 200 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; + return n.kind === 203 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 200 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; + return n.kind === 203 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { @@ -13713,7 +14385,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 230 /* ExpressionStatement */ + return node.kind === 233 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -13741,11 +14413,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 159 /* Parameter */ || - node.kind === 158 /* TypeParameter */ || - node.kind === 205 /* FunctionExpression */ || - node.kind === 206 /* ArrowFunction */ || - node.kind === 204 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 160 /* Parameter */ || + node.kind === 159 /* TypeParameter */ || + node.kind === 208 /* FunctionExpression */ || + node.kind === 209 /* ArrowFunction */ || + node.kind === 207 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -13761,48 +14433,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/; var defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/; function isPartOfTypeNode(node) { - if (171 /* FirstTypeNode */ <= node.kind && node.kind <= 192 /* LastTypeNode */) { + if (172 /* FirstTypeNode */ <= node.kind && node.kind <= 195 /* LastTypeNode */) { return true; } switch (node.kind) { case 128 /* AnyKeyword */: - case 151 /* UnknownKeyword */: - case 143 /* NumberKeyword */: - case 154 /* BigIntKeyword */: - case 146 /* StringKeyword */: + case 152 /* UnknownKeyword */: + case 144 /* NumberKeyword */: + case 155 /* BigIntKeyword */: + case 147 /* StringKeyword */: case 131 /* BooleanKeyword */: - case 147 /* SymbolKeyword */: - case 144 /* ObjectKeyword */: - case 149 /* UndefinedKeyword */: - case 140 /* NeverKeyword */: + case 148 /* SymbolKeyword */: + case 145 /* ObjectKeyword */: + case 150 /* UndefinedKeyword */: + case 141 /* NeverKeyword */: return true; case 113 /* VoidKeyword */: - return node.parent.kind !== 209 /* VoidExpression */; - case 220 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 212 /* VoidExpression */; + case 223 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 158 /* TypeParameter */: - return node.parent.kind === 189 /* MappedType */ || node.parent.kind === 184 /* InferType */; + case 159 /* TypeParameter */: + return node.parent.kind === 190 /* MappedType */ || node.parent.kind === 185 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 78 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 156 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 198 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 78 /* Identifier */ || node.kind === 156 /* QualifiedName */ || node.kind === 198 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */ || node.kind === 201 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 156 /* QualifiedName */: - case 198 /* PropertyAccessExpression */: + case 157 /* QualifiedName */: + case 201 /* PropertyAccessExpression */: case 107 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 175 /* TypeQuery */) { + if (parent.kind === 176 /* TypeQuery */) { return false; } - if (parent.kind === 192 /* ImportType */) { + if (parent.kind === 195 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -13811,40 +14483,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (171 /* FirstTypeNode */ <= parent.kind && parent.kind <= 192 /* LastTypeNode */) { + if (172 /* FirstTypeNode */ <= parent.kind && parent.kind <= 195 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: return node === parent.constraint; - case 326 /* JSDocTemplateTag */: + case 330 /* JSDocTemplateTag */: return node === parent.constraint; - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 159 /* Parameter */: - case 246 /* VariableDeclaration */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 160 /* Parameter */: + case 249 /* VariableDeclaration */: return node === parent.type; - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 165 /* Constructor */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 166 /* Constructor */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return node === parent.type; - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 170 /* IndexSignature */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 171 /* IndexSignature */: return node === parent.type; - case 203 /* TypeAssertionExpression */: + case 206 /* TypeAssertionExpression */: return node === parent.type; - case 200 /* CallExpression */: - case 201 /* NewExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -13869,23 +14541,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: return visitor(node); - case 255 /* CaseBlock */: - case 227 /* Block */: - case 231 /* IfStatement */: - case 232 /* DoStatement */: - case 233 /* WhileStatement */: - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 240 /* WithStatement */: - case 241 /* SwitchStatement */: - case 281 /* CaseClause */: - case 282 /* DefaultClause */: - case 242 /* LabeledStatement */: - case 244 /* TryStatement */: - case 284 /* CatchClause */: + case 258 /* CaseBlock */: + case 230 /* Block */: + case 234 /* IfStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 243 /* WithStatement */: + case 244 /* SwitchStatement */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: + case 245 /* LabeledStatement */: + case 247 /* TryStatement */: + case 287 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -13895,23 +14567,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 252 /* EnumDeclaration */: - case 250 /* InterfaceDeclaration */: - case 253 /* ModuleDeclaration */: - case 251 /* TypeAliasDeclaration */: + case 255 /* EnumDeclaration */: + case 253 /* InterfaceDeclaration */: + case 256 /* ModuleDeclaration */: + case 254 /* TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 157 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 158 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -13934,10 +14606,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 177 /* ArrayType */) { + if (node && node.kind === 178 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 172 /* TypeReference */) { + else if (node && node.kind === 173 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -13947,12 +14619,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 250 /* InterfaceDeclaration */: - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 176 /* TypeLiteral */: + case 253 /* InterfaceDeclaration */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 177 /* TypeLiteral */: return node.members; - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return node.properties; } } @@ -13960,14 +14632,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 195 /* BindingElement */: - case 288 /* EnumMember */: - case 159 /* Parameter */: - case 285 /* PropertyAssignment */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 286 /* ShorthandPropertyAssignment */: - case 246 /* VariableDeclaration */: + case 198 /* BindingElement */: + case 291 /* EnumMember */: + case 160 /* Parameter */: + case 288 /* PropertyAssignment */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 289 /* ShorthandPropertyAssignment */: + case 249 /* VariableDeclaration */: return true; } } @@ -13979,8 +14651,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 247 /* VariableDeclarationList */ - && node.parent.parent.kind === 229 /* VariableStatement */; + return node.parent.kind === 250 /* VariableDeclarationList */ + && node.parent.parent.kind === 232 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -13991,13 +14663,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: return true; } return false; @@ -14008,7 +14680,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 242 /* LabeledStatement */) { + if (node.statement.kind !== 245 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -14016,17 +14688,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 227 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 230 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 164 /* MethodDeclaration */ && node.parent.kind === 197 /* ObjectLiteralExpression */; + return node && node.kind === 165 /* MethodDeclaration */ && node.parent.kind === 200 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 164 /* MethodDeclaration */ && - (node.parent.kind === 197 /* ObjectLiteralExpression */ || - node.parent.kind === 218 /* ClassExpression */); + return node.kind === 165 /* MethodDeclaration */ && + (node.parent.kind === 200 /* ObjectLiteralExpression */ || + node.parent.kind === 221 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -14039,7 +14711,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 285 /* PropertyAssignment */) { + if (property.kind === 288 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -14068,26 +14740,26 @@ var ts; } ts.getTsConfigPropArray = getTsConfigPropArray; function getContainingFunction(node) { - return findAncestor(node.parent, ts.isFunctionLike); + return ts.findAncestor(node.parent, ts.isFunctionLike); } ts.getContainingFunction = getContainingFunction; function getContainingFunctionDeclaration(node) { - return findAncestor(node.parent, ts.isFunctionLikeDeclaration); + return ts.findAncestor(node.parent, ts.isFunctionLikeDeclaration); } ts.getContainingFunctionDeclaration = getContainingFunctionDeclaration; function getContainingClass(node) { - return findAncestor(node.parent, ts.isClassLike); + return ts.findAncestor(node.parent, ts.isClassLike); } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 294 /* SourceFile */); + ts.Debug.assert(node.kind !== 297 /* SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -14102,9 +14774,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 160 /* Decorator */: + case 161 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 159 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -14115,26 +14787,26 @@ var ts; node = node.parent; } break; - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 253 /* ModuleDeclaration */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 170 /* IndexSignature */: - case 252 /* EnumDeclaration */: - case 294 /* SourceFile */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 256 /* ModuleDeclaration */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 171 /* IndexSignature */: + case 255 /* EnumDeclaration */: + case 297 /* SourceFile */: return node; } } @@ -14153,9 +14825,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 165 /* Constructor */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: + case 166 /* Constructor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: return container; } } @@ -14177,27 +14849,27 @@ var ts; return node; } switch (node.kind) { - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: node = node.parent; break; - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return node; - case 160 /* Decorator */: + case 161 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 159 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -14213,14 +14885,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 205 /* FunctionExpression */ || func.kind === 206 /* ArrowFunction */) { + if (func.kind === 208 /* FunctionExpression */ || func.kind === 209 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 204 /* ParenthesizedExpression */) { + while (parent.kind === 207 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 200 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 203 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -14236,7 +14908,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 198 /* PropertyAccessExpression */ || kind === 199 /* ElementAccessExpression */) + return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) && node.expression.kind === 105 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -14245,21 +14917,26 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 198 /* PropertyAccessExpression */ || kind === 199 /* ElementAccessExpression */) + return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) && node.expression.kind === 107 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; + function isThisInitializedDeclaration(node) { + var _a; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 107 /* ThisKeyword */; + } + ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 172 /* TypeReference */: + case 173 /* TypeReference */: return node.typeName; - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. case 78 /* Identifier */: - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: return node; } return undefined; @@ -14267,10 +14944,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return node.tag; - case 272 /* JsxOpeningElement */: - case 271 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: + case 274 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -14283,25 +14960,25 @@ var ts; return false; } switch (node.kind) { - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: // classes are valid targets return true; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 249 /* ClassDeclaration */; - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 164 /* MethodDeclaration */: + return parent.kind === 252 /* ClassDeclaration */; + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 165 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 249 /* ClassDeclaration */; - case 159 /* Parameter */: + && parent.kind === 252 /* ClassDeclaration */; + case 160 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 165 /* Constructor */ - || parent.kind === 164 /* MethodDeclaration */ - || parent.kind === 167 /* SetAccessor */) - && grandparent.kind === 249 /* ClassDeclaration */; + && (parent.kind === 166 /* Constructor */ + || parent.kind === 165 /* MethodDeclaration */ + || parent.kind === 168 /* SetAccessor */) + && grandparent.kind === 252 /* ClassDeclaration */; } return false; } @@ -14317,10 +14994,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 164 /* MethodDeclaration */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 168 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -14329,9 +15006,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 272 /* JsxOpeningElement */ || - parent.kind === 271 /* JsxSelfClosingElement */ || - parent.kind === 273 /* JsxClosingElement */) { + if (parent.kind === 275 /* JsxOpeningElement */ || + parent.kind === 274 /* JsxSelfClosingElement */ || + parent.kind === 276 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -14344,44 +15021,44 @@ var ts; case 109 /* TrueKeyword */: case 94 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 196 /* ArrayLiteralExpression */: - case 197 /* ObjectLiteralExpression */: - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: - case 200 /* CallExpression */: - case 201 /* NewExpression */: - case 202 /* TaggedTemplateExpression */: - case 221 /* AsExpression */: - case 203 /* TypeAssertionExpression */: - case 222 /* NonNullExpression */: - case 204 /* ParenthesizedExpression */: - case 205 /* FunctionExpression */: - case 218 /* ClassExpression */: - case 206 /* ArrowFunction */: - case 209 /* VoidExpression */: - case 207 /* DeleteExpression */: - case 208 /* TypeOfExpression */: - case 211 /* PrefixUnaryExpression */: - case 212 /* PostfixUnaryExpression */: - case 213 /* BinaryExpression */: - case 214 /* ConditionalExpression */: - case 217 /* SpreadElement */: - case 215 /* TemplateExpression */: - case 219 /* OmittedExpression */: - case 270 /* JsxElement */: - case 271 /* JsxSelfClosingElement */: - case 274 /* JsxFragment */: - case 216 /* YieldExpression */: - case 210 /* AwaitExpression */: - case 223 /* MetaProperty */: + case 199 /* ArrayLiteralExpression */: + case 200 /* ObjectLiteralExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: + case 205 /* TaggedTemplateExpression */: + case 224 /* AsExpression */: + case 206 /* TypeAssertionExpression */: + case 225 /* NonNullExpression */: + case 207 /* ParenthesizedExpression */: + case 208 /* FunctionExpression */: + case 221 /* ClassExpression */: + case 209 /* ArrowFunction */: + case 212 /* VoidExpression */: + case 210 /* DeleteExpression */: + case 211 /* TypeOfExpression */: + case 214 /* PrefixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: + case 216 /* BinaryExpression */: + case 217 /* ConditionalExpression */: + case 220 /* SpreadElement */: + case 218 /* TemplateExpression */: + case 222 /* OmittedExpression */: + case 273 /* JsxElement */: + case 274 /* JsxSelfClosingElement */: + case 277 /* JsxFragment */: + case 219 /* YieldExpression */: + case 213 /* AwaitExpression */: + case 226 /* MetaProperty */: return true; - case 156 /* QualifiedName */: - while (node.parent.kind === 156 /* QualifiedName */) { + case 157 /* QualifiedName */: + while (node.parent.kind === 157 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 175 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node); case 78 /* Identifier */: - if (node.parent.kind === 175 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -14399,49 +15076,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 246 /* VariableDeclaration */: - case 159 /* Parameter */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 288 /* EnumMember */: - case 285 /* PropertyAssignment */: - case 195 /* BindingElement */: + case 249 /* VariableDeclaration */: + case 160 /* Parameter */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 291 /* EnumMember */: + case 288 /* PropertyAssignment */: + case 198 /* BindingElement */: return parent.initializer === node; - case 230 /* ExpressionStatement */: - case 231 /* IfStatement */: - case 232 /* DoStatement */: - case 233 /* WhileStatement */: - case 239 /* ReturnStatement */: - case 240 /* WithStatement */: - case 241 /* SwitchStatement */: - case 281 /* CaseClause */: - case 243 /* ThrowStatement */: + case 233 /* ExpressionStatement */: + case 234 /* IfStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: + case 242 /* ReturnStatement */: + case 243 /* WithStatement */: + case 244 /* SwitchStatement */: + case 284 /* CaseClause */: + case 246 /* ThrowStatement */: return parent.expression === node; - case 234 /* ForStatement */: + case 237 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 247 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 250 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 247 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250 /* VariableDeclarationList */) || forInStatement.expression === node; - case 203 /* TypeAssertionExpression */: - case 221 /* AsExpression */: + case 206 /* TypeAssertionExpression */: + case 224 /* AsExpression */: return node === parent.expression; - case 225 /* TemplateSpan */: + case 228 /* TemplateSpan */: return node === parent.expression; - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: return node === parent.expression; - case 160 /* Decorator */: - case 280 /* JsxExpression */: - case 279 /* JsxSpreadAttribute */: - case 287 /* SpreadAssignment */: + case 161 /* Decorator */: + case 283 /* JsxExpression */: + case 282 /* JsxSpreadAttribute */: + case 290 /* SpreadAssignment */: return true; - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -14449,14 +15126,14 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 156 /* QualifiedName */ || node.kind === 78 /* Identifier */) { + while (node.kind === 157 /* QualifiedName */ || node.kind === 78 /* Identifier */) { node = node.parent; } - return node.kind === 175 /* TypeQuery */; + return node.kind === 176 /* TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 257 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 269 /* ExternalModuleReference */; + return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 272 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -14464,8 +15141,13 @@ var ts; return node.moduleReference.expression; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function getExternalModuleRequireArgument(node) { + return isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) + && getLeftmostAccessExpression(node.initializer).arguments[0]; + } + ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 257 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 269 /* ExternalModuleReference */; + return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 272 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -14497,11 +15179,11 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 146 /* StringKeyword */ || node.typeArguments[0].kind === 143 /* NumberKeyword */); + (node.typeArguments[0].kind === 147 /* StringKeyword */ || node.typeArguments[0].kind === 144 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 200 /* CallExpression */) { + if (callExpression.kind !== 203 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -14516,7 +15198,10 @@ var ts; } ts.isRequireCall = isRequireCall; function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) { - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(node.initializer, requireStringLiteralLikeArgument); + if (node.kind === 198 /* BindingElement */) { + node = node.parent.parent; + } + return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument); } ts.isRequireVariableDeclaration = isRequireVariableDeclaration; function isRequireVariableStatement(node, requireStringLiteralLikeArgument) { @@ -14534,46 +15219,6 @@ var ts; return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; - function getDeclarationOfExpando(node) { - if (!node.parent) { - return undefined; - } - var name; - var decl; - if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) { - if (!isInJSFile(node) && !isVarConst(node.parent)) { - return undefined; - } - name = node.parent.name; - decl = node.parent; - } - else if (ts.isBinaryExpression(node.parent)) { - var parentNode = node.parent; - var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { - name = parentNode.left; - decl = name; - } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { - if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { - name = parentNode.parent.name; - decl = parentNode.parent; - } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { - name = parentNode.parent.left; - decl = name; - } - if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { - return undefined; - } - } - } - if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { - return undefined; - } - return decl; - } - ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } @@ -14635,11 +15280,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 205 /* FunctionExpression */ || e.kind === 206 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 208 /* FunctionExpression */ || e.kind === 209 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 205 /* FunctionExpression */ || - initializer.kind === 218 /* ClassExpression */ || - initializer.kind === 206 /* ArrowFunction */) { + if (initializer.kind === 208 /* FunctionExpression */ || + initializer.kind === 221 /* ClassExpression */ || + initializer.kind === 209 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -14714,6 +15359,7 @@ var ts; } return false; } + ts.isSameEntityName = isSameEntityName; function getRightMostAssignedExpression(node) { while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; @@ -14892,7 +15538,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 230 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 233 /* ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -14913,7 +15559,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 248 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 251 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -14922,14 +15568,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 258 /* ImportDeclaration */: - case 264 /* ExportDeclaration */: + case 261 /* ImportDeclaration */: + case 267 /* ExportDeclaration */: return node.parent; - case 269 /* ExternalModuleReference */: + case 272 /* ExternalModuleReference */: return node.parent.parent; - case 200 /* CallExpression */: + case 203 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 190 /* LiteralType */: + case 191 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -14939,12 +15585,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: - case 264 /* ExportDeclaration */: + case 261 /* ImportDeclaration */: + case 267 /* ExportDeclaration */: return node.moduleSpecifier; - case 257 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 269 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 192 /* ImportType */: + case 260 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 272 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 195 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -14953,11 +15599,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return node; - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -14965,7 +15611,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 258 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 261 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -14986,13 +15632,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 159 /* Parameter */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 286 /* ShorthandPropertyAssignment */: - case 285 /* PropertyAssignment */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 160 /* Parameter */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 289 /* ShorthandPropertyAssignment */: + case 288 /* PropertyAssignment */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -15006,7 +15652,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 327 /* JSDocTypedefTag */ || node.kind === 320 /* JSDocCallbackTag */ || node.kind === 321 /* JSDocEnumTag */; + return node.kind === 331 /* JSDocTypedefTag */ || node.kind === 324 /* JSDocCallbackTag */ || node.kind === 325 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -15031,12 +15677,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return node.initializer; - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return node.initializer; } } @@ -15048,7 +15694,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 253 /* ModuleDeclaration */ + node.body.kind === 256 /* ModuleDeclaration */ ? node.body : undefined; } @@ -15063,11 +15709,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 159 /* Parameter */) { + if (node.kind === 160 /* Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 158 /* TypeParameter */) { + if (node.kind === 159 /* TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -15078,10 +15724,10 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 285 /* PropertyAssignment */ || - parent.kind === 263 /* ExportAssignment */ || - parent.kind === 162 /* PropertyDeclaration */ || - parent.kind === 230 /* ExpressionStatement */ && node.kind === 198 /* PropertyAccessExpression */ || + if (parent.kind === 288 /* PropertyAssignment */ || + parent.kind === 266 /* ExportAssignment */ || + parent.kind === 163 /* PropertyDeclaration */ || + parent.kind === 233 /* ExpressionStatement */ && node.kind === 201 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; @@ -15139,7 +15785,7 @@ var ts; ts.getEffectiveJSDocHost = getEffectiveJSDocHost; /** Use getEffectiveJSDocHost if you additionally need to look for jsdoc on parent nodes, like assignments. */ function getJSDocHost(node) { - return ts.Debug.checkDefined(findAncestor(node.parent, ts.isJSDoc)).parent; + return ts.Debug.checkDefined(ts.findAncestor(node.parent, ts.isJSDoc)).parent; } ts.getJSDocHost = getJSDocHost; function getTypeParameterFromJsDoc(node) { @@ -15155,7 +15801,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 305 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 309 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -15172,31 +15818,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 211 /* PrefixUnaryExpression */: - case 212 /* PostfixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 204 /* ParenthesizedExpression */: - case 196 /* ArrayLiteralExpression */: - case 217 /* SpreadElement */: - case 222 /* NonNullExpression */: + case 207 /* ParenthesizedExpression */: + case 199 /* ArrayLiteralExpression */: + case 220 /* SpreadElement */: + case 225 /* NonNullExpression */: node = parent; break; - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -15223,22 +15869,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 227 /* Block */: - case 229 /* VariableStatement */: - case 240 /* WithStatement */: - case 231 /* IfStatement */: - case 241 /* SwitchStatement */: - case 255 /* CaseBlock */: - case 281 /* CaseClause */: - case 282 /* DefaultClause */: - case 242 /* LabeledStatement */: - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 232 /* DoStatement */: - case 233 /* WhileStatement */: - case 244 /* TryStatement */: - case 284 /* CatchClause */: + case 230 /* Block */: + case 232 /* VariableStatement */: + case 243 /* WithStatement */: + case 234 /* IfStatement */: + case 244 /* SwitchStatement */: + case 258 /* CaseBlock */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: + case 245 /* LabeledStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: + case 247 /* TryStatement */: + case 287 /* CatchClause */: return true; } return false; @@ -15255,30 +15901,44 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 185 /* ParenthesizedType */); + return walkUp(node, 186 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 204 /* ParenthesizedExpression */); + return walkUp(node, 207 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; + /** + * Walks up parenthesized types. + * It returns both the outermost parenthesized type and its parent. + * If given node is not a parenthesiezd type, undefined is return as the former. + */ + function walkUpParenthesizedTypesAndGetParentAndChild(node) { + var child; + while (node && node.kind === 186 /* ParenthesizedType */) { + child = node; + node = node.parent; + } + return [child, node]; + } + ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild; function skipParentheses(node) { return ts.skipOuterExpressions(node, 1 /* Parentheses */); } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 204 /* ParenthesizedExpression */) { + while (node.kind === 207 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 198 /* PropertyAccessExpression */ && node.kind !== 199 /* ElementAccessExpression */) { + if (node.kind !== 201 /* PropertyAccessExpression */ && node.kind !== 202 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 207 /* DeleteExpression */; + return node && node.kind === 210 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -15331,7 +15991,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 157 /* ComputedPropertyName */ && + node.parent.kind === 158 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -15339,26 +15999,26 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 288 /* EnumMember */: - case 285 /* PropertyAssignment */: - case 198 /* PropertyAccessExpression */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 291 /* EnumMember */: + case 288 /* PropertyAssignment */: + case 201 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 195 /* BindingElement */: - case 262 /* ImportSpecifier */: + case 198 /* BindingElement */: + case 265 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 267 /* ExportSpecifier */: - case 277 /* JsxAttribute */: + case 270 /* ExportSpecifier */: + case 280 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -15378,33 +16038,33 @@ var ts; // {<Identifier>} // {name: <EntityNameExpression>} function isAliasSymbolDeclaration(node) { - return node.kind === 257 /* ImportEqualsDeclaration */ || - node.kind === 256 /* NamespaceExportDeclaration */ || - node.kind === 259 /* ImportClause */ && !!node.name || - node.kind === 260 /* NamespaceImport */ || - node.kind === 266 /* NamespaceExport */ || - node.kind === 262 /* ImportSpecifier */ || - node.kind === 267 /* ExportSpecifier */ || - node.kind === 263 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 260 /* ImportEqualsDeclaration */ || + node.kind === 259 /* NamespaceExportDeclaration */ || + node.kind === 262 /* ImportClause */ && !!node.name || + node.kind === 263 /* NamespaceImport */ || + node.kind === 269 /* NamespaceExport */ || + node.kind === 265 /* ImportSpecifier */ || + node.kind === 270 /* ExportSpecifier */ || + node.kind === 266 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 286 /* ShorthandPropertyAssignment */ || - node.kind === 285 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + node.kind === 289 /* ShorthandPropertyAssignment */ || + node.kind === 288 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 259 /* ImportClause */: - case 262 /* ImportSpecifier */: - case 260 /* NamespaceImport */: - case 267 /* ExportSpecifier */: - case 263 /* ExportAssignment */: - case 257 /* ImportEqualsDeclaration */: + case 262 /* ImportClause */: + case 265 /* ImportSpecifier */: + case 263 /* NamespaceImport */: + case 270 /* ExportSpecifier */: + case 266 /* ExportAssignment */: + case 260 /* ImportEqualsDeclaration */: return node.parent; - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 156 /* QualifiedName */); + } while (node.parent.kind === 157 /* QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -15423,7 +16083,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 286 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 285 /* PropertyAssignment */ ? node.initializer : + return node.kind === 289 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 288 /* PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -15489,11 +16149,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 80 /* FirstKeyword */ <= token && token <= 155 /* LastKeyword */; + return 80 /* FirstKeyword */ <= token && token <= 156 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 125 /* FirstContextualKeyword */ <= token && token <= 155 /* LastContextualKeyword */; + return 125 /* FirstContextualKeyword */ <= token && token <= 156 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -15537,14 +16197,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 164 /* MethodDeclaration */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 165 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: if (hasSyntacticModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -15558,10 +16218,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 164 /* MethodDeclaration */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 165 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256 /* Async */); @@ -15594,7 +16254,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 157 /* ComputedPropertyName */ || name.kind === 199 /* ElementAccessExpression */)) { + if (!(name.kind === 158 /* ComputedPropertyName */ || name.kind === 202 /* ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -15620,7 +16280,7 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -15689,11 +16349,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 159 /* Parameter */; + return root.kind === 160 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 195 /* BindingElement */) { + while (node.kind === 198 /* BindingElement */) { node = node.parent.parent; } return node; @@ -15701,15 +16361,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 165 /* Constructor */ - || kind === 205 /* FunctionExpression */ - || kind === 248 /* FunctionDeclaration */ - || kind === 206 /* ArrowFunction */ - || kind === 164 /* MethodDeclaration */ - || kind === 166 /* GetAccessor */ - || kind === 167 /* SetAccessor */ - || kind === 253 /* ModuleDeclaration */ - || kind === 294 /* SourceFile */; + return kind === 166 /* Constructor */ + || kind === 208 /* FunctionExpression */ + || kind === 251 /* FunctionDeclaration */ + || kind === 209 /* ArrowFunction */ + || kind === 165 /* MethodDeclaration */ + || kind === 167 /* GetAccessor */ + || kind === 168 /* SetAccessor */ + || kind === 256 /* ModuleDeclaration */ + || kind === 297 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -15728,23 +16388,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 201 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 201 /* NewExpression */: + case 204 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 211 /* PrefixUnaryExpression */: - case 208 /* TypeOfExpression */: - case 209 /* VoidExpression */: - case 207 /* DeleteExpression */: - case 210 /* AwaitExpression */: - case 214 /* ConditionalExpression */: - case 216 /* YieldExpression */: + case 214 /* PrefixUnaryExpression */: + case 211 /* TypeOfExpression */: + case 212 /* VoidExpression */: + case 210 /* DeleteExpression */: + case 213 /* AwaitExpression */: + case 217 /* ConditionalExpression */: + case 219 /* YieldExpression */: return 1 /* Right */; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: switch (operator) { case 42 /* AsteriskAsteriskToken */: case 62 /* EqualsToken */: @@ -15771,15 +16431,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 201 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 213 /* BinaryExpression */) { + if (expression.kind === 216 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 211 /* PrefixUnaryExpression */ || expression.kind === 212 /* PostfixUnaryExpression */) { + else if (expression.kind === 214 /* PrefixUnaryExpression */ || expression.kind === 215 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -15958,15 +16618,15 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 332 /* CommaListExpression */: + case 337 /* CommaListExpression */: return 0 /* Comma */; - case 217 /* SpreadElement */: + case 220 /* SpreadElement */: return 1 /* Spread */; - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: return 2 /* Yield */; - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return 4 /* Conditional */; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0 /* Comma */; @@ -15992,21 +16652,21 @@ var ts; } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? // TODO: We are missing `TypeAssertionExpression` - case 211 /* PrefixUnaryExpression */: - case 208 /* TypeOfExpression */: - case 209 /* VoidExpression */: - case 207 /* DeleteExpression */: - case 210 /* AwaitExpression */: + case 214 /* PrefixUnaryExpression */: + case 211 /* TypeOfExpression */: + case 212 /* VoidExpression */: + case 210 /* DeleteExpression */: + case 213 /* AwaitExpression */: return 16 /* Unary */; - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: return 17 /* Update */; - case 200 /* CallExpression */: + case 203 /* CallExpression */: return 18 /* LeftHandSide */; - case 201 /* NewExpression */: + case 204 /* NewExpression */: return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 202 /* TaggedTemplateExpression */: - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 205 /* TaggedTemplateExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: return 19 /* Member */; case 107 /* ThisKeyword */: case 105 /* SuperKeyword */: @@ -16017,19 +16677,19 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 196 /* ArrayLiteralExpression */: - case 197 /* ObjectLiteralExpression */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 218 /* ClassExpression */: + case 199 /* ArrayLiteralExpression */: + case 200 /* ObjectLiteralExpression */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 221 /* ClassExpression */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 215 /* TemplateExpression */: - case 204 /* ParenthesizedExpression */: - case 219 /* OmittedExpression */: - case 270 /* JsxElement */: - case 271 /* JsxSelfClosingElement */: - case 274 /* JsxFragment */: + case 218 /* TemplateExpression */: + case 207 /* ParenthesizedExpression */: + case 222 /* OmittedExpression */: + case 273 /* JsxElement */: + case 274 /* JsxSelfClosingElement */: + case 277 /* JsxFragment */: return 20 /* Primary */; default: return -1 /* Invalid */; @@ -16082,6 +16742,19 @@ var ts; return -1; } ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence; + function getSemanticJsxChildren(children) { + return ts.filter(children, function (i) { + switch (i.kind) { + case 283 /* JsxExpression */: + return !!i.expression; + case 11 /* JsxText */: + return !i.containsOnlyTriviaWhiteSpaces; + default: + return true; + } + }); + } + ts.getSemanticJsxChildren = getSemanticJsxChildren; function createDiagnosticCollection() { var nonFileDiagnostics = []; // See GH#19873 var filesWithDiagnostics = []; @@ -16276,8 +16949,10 @@ var ts; ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + // prepopulate cache + var singleLevel = indentStrings[1]; + for (var current = indentStrings.length; current <= level; current++) { + indentStrings.push(indentStrings[current - 1] + singleLevel); } return indentStrings[level]; } @@ -16516,6 +17191,14 @@ var ts; return options.outFile || options.out; } ts.outFile = outFile; + /** Returns 'undefined' if and only if 'options.paths' is undefined. */ + function getPathsBasePath(options, host) { + var _a, _b; + if (!options.paths) + return undefined; + return (_a = options.baseUrl) !== null && _a !== void 0 ? _a : ts.Debug.checkDefined(options.pathsBasePath || ((_b = host.getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(host)), "Encountered 'paths' without a 'baseUrl', config file, or host 'getCurrentDirectory'."); + } + ts.getPathsBasePath = getPathsBasePath; /** * Gets the source files that are expected to have an emit output. * @@ -16644,10 +17327,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 166 /* GetAccessor */) { + if (accessor.kind === 167 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 167 /* SetAccessor */) { + else if (accessor.kind === 168 /* SetAccessor */) { setAccessor = accessor; } else { @@ -16667,10 +17350,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 166 /* GetAccessor */ && !getAccessor) { + if (member.kind === 167 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 167 /* SetAccessor */ && !setAccessor) { + if (member.kind === 168 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -16719,7 +17402,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 307 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 311 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -16955,7 +17638,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 155 /* LastToken */) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 156 /* LastToken */) { return 0 /* None */; } if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { @@ -17051,7 +17734,7 @@ var ts; case 84 /* ConstKeyword */: return 2048 /* Const */; case 87 /* DefaultKeyword */: return 512 /* Default */; case 129 /* AsyncKeyword */: return 256 /* Async */; - case 141 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 142 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } @@ -17101,8 +17784,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 197 /* ObjectLiteralExpression */ - || kind === 196 /* ArrayLiteralExpression */; + return kind === 200 /* ObjectLiteralExpression */ + || kind === 199 /* ArrayLiteralExpression */; } return false; } @@ -17119,12 +17802,12 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return node; - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: do { node = node.left; } while (node.kind !== 78 /* Identifier */); return node; - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 78 /* Identifier */); @@ -17134,8 +17817,8 @@ var ts; ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { return node.kind === 78 /* Identifier */ || node.kind === 107 /* ThisKeyword */ || node.kind === 105 /* SuperKeyword */ || - node.kind === 198 /* PropertyAccessExpression */ && isDottedName(node.expression) || - node.kind === 204 /* ParenthesizedExpression */ && isDottedName(node.expression); + node.kind === 201 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 207 /* ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -17160,17 +17843,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 156 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 198 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 197 /* ObjectLiteralExpression */ && + return expression.kind === 200 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 196 /* ArrayLiteralExpression */ && + return expression.kind === 199 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -17502,8 +18185,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 252 /* EnumDeclaration */: - case 253 /* ModuleDeclaration */: + case 255 /* EnumDeclaration */: + case 256 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -17580,35 +18263,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return accessKind(parent); - case 212 /* PostfixUnaryExpression */: - case 211 /* PrefixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 285 /* PropertyAssignment */: { + case 288 /* PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && skipParenthesesUp(parent.parent).kind === 230 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 233 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -17757,37 +18440,37 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 171 /* FirstTypeNode */ && kind <= 192 /* LastTypeNode */) + return (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) || kind === 128 /* AnyKeyword */ - || kind === 151 /* UnknownKeyword */ - || kind === 143 /* NumberKeyword */ - || kind === 154 /* BigIntKeyword */ - || kind === 144 /* ObjectKeyword */ + || kind === 152 /* UnknownKeyword */ + || kind === 144 /* NumberKeyword */ + || kind === 155 /* BigIntKeyword */ + || kind === 145 /* ObjectKeyword */ || kind === 131 /* BooleanKeyword */ - || kind === 146 /* StringKeyword */ - || kind === 147 /* SymbolKeyword */ + || kind === 147 /* StringKeyword */ + || kind === 148 /* SymbolKeyword */ || kind === 113 /* VoidKeyword */ - || kind === 149 /* UndefinedKeyword */ - || kind === 140 /* NeverKeyword */ - || kind === 220 /* ExpressionWithTypeArguments */ - || kind === 299 /* JSDocAllType */ - || kind === 300 /* JSDocUnknownType */ - || kind === 301 /* JSDocNullableType */ - || kind === 302 /* JSDocNonNullableType */ - || kind === 303 /* JSDocOptionalType */ - || kind === 304 /* JSDocFunctionType */ - || kind === 305 /* JSDocVariadicType */; + || kind === 150 /* UndefinedKeyword */ + || kind === 141 /* NeverKeyword */ + || kind === 223 /* ExpressionWithTypeArguments */ + || kind === 303 /* JSDocAllType */ + || kind === 304 /* JSDocUnknownType */ + || kind === 305 /* JSDocNullableType */ + || kind === 306 /* JSDocNonNullableType */ + || kind === 307 /* JSDocOptionalType */ + || kind === 308 /* JSDocFunctionType */ + || kind === 309 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 198 /* PropertyAccessExpression */ || node.kind === 199 /* ElementAccessExpression */; + return node.kind === 201 /* PropertyAccessExpression */ || node.kind === 202 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 198 /* PropertyAccessExpression */) { + if (node.kind === 201 /* PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 199 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 202 /* ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -17802,34 +18485,41 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 261 /* NamedImports */ || node.kind === 265 /* NamedExports */; + return node.kind === 264 /* NamedImports */ || node.kind === 268 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; + function getLeftmostAccessExpression(expr) { + while (isAccessExpression(expr)) { + expr = expr.expression; + } + return expr; + } + ts.getLeftmostAccessExpression = getLeftmostAccessExpression; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: node = node.operand; continue; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: node = node.left; continue; - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: node = node.condition; continue; - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: node = node.tag; continue; - case 200 /* CallExpression */: + case 203 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 221 /* AsExpression */: - case 199 /* ElementAccessExpression */: - case 198 /* PropertyAccessExpression */: - case 222 /* NonNullExpression */: - case 331 /* PartiallyEmittedExpression */: + case 224 /* AsExpression */: + case 202 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 225 /* NonNullExpression */: + case 336 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -17848,7 +18538,7 @@ var ts; } function Type(checker, flags) { this.flags = flags; - if (ts.Debug.isDebugging) { + if (ts.Debug.isDebugging || ts.tracing.isTracing()) { this.checker = checker; } } @@ -18205,6 +18895,10 @@ var ts; return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } ts.getStrictOptionValue = getStrictOptionValue; + function getAllowJSCompilerOption(compilerOptions) { + return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs; + } + ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { return oldOptions !== newOptions && ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); @@ -18219,6 +18913,26 @@ var ts; return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; } ts.getCompilerOptionValue = getCompilerOptionValue; + function getJSXTransformEnabled(options) { + var jsx = options.jsx; + return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + } + ts.getJSXTransformEnabled = getJSXTransformEnabled; + function getJSXImplicitImportBase(compilerOptions, file) { + var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); + var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[0] : jsxImportSourcePragmas; + return compilerOptions.jsx === 4 /* ReactJSX */ || + compilerOptions.jsx === 5 /* ReactJSXDev */ || + compilerOptions.jsxImportSource || + jsxImportSourcePragma ? + (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : + undefined; + } + ts.getJSXImplicitImportBase = getJSXImplicitImportBase; + function getJSXRuntimeImport(base, options) { + return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + } + ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { @@ -18598,7 +19312,7 @@ var ts; var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { - var needJsExtensions = options && options.allowJs; + var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } @@ -18809,6 +19523,7 @@ var ts; if (!diagnostic.relatedInformation) { diagnostic.relatedInformation = []; } + ts.Debug.assert(diagnostic.relatedInformation !== ts.emptyArray, "Diagnostic had empty array singleton for related info, but is still being constructed!"); (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); return diagnostic; } @@ -18937,38 +19652,38 @@ var ts; } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - return typeOnlyDeclaration.kind === 267 /* ExportSpecifier */; + return typeOnlyDeclaration.kind === 270 /* ExportSpecifier */; } ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 78 /* Identifier */ || node.kind === 198 /* PropertyAccessExpression */) { + while (node.kind === 78 /* Identifier */ || node.kind === 201 /* PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 157 /* ComputedPropertyName */) { + if (node.kind !== 158 /* ComputedPropertyName */) { return false; } if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 250 /* InterfaceDeclaration */ || containerKind === 176 /* TypeLiteral */; + return containerKind === 253 /* InterfaceDeclaration */ || containerKind === 177 /* TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { if (node.kind !== 78 /* Identifier */) return false; - var heritageClause = findAncestor(node.parent, function (parent) { + var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 283 /* HeritageClause */: + case 286 /* HeritageClause */: return true; - case 198 /* PropertyAccessExpression */: - case 220 /* ExpressionWithTypeArguments */: + case 201 /* PropertyAccessExpression */: + case 223 /* ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 250 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253 /* InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -19162,10 +19877,10 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(213 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(213 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(216 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(216 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 206 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 209 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -19177,7 +19892,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 216 /* YieldExpression */) { + && operand.kind === 219 /* YieldExpression */) { return false; } return true; @@ -19265,7 +19980,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 213 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -19291,7 +20006,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 204 /* ParenthesizedExpression */) { + if (skipped.kind === 207 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -19308,7 +20023,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(214 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(217 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { @@ -19341,8 +20056,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 218 /* ClassExpression */: - case 205 /* FunctionExpression */: + case 221 /* ClassExpression */: + case 208 /* FunctionExpression */: needsParens = true; } } @@ -19355,9 +20070,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 200 /* CallExpression */: + case 203 /* CallExpression */: return factory.createParenthesizedExpression(expression); - case 201 /* NewExpression */: + case 204 /* NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -19377,7 +20092,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 201 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 204 /* NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -19399,7 +20114,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(213 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(216 /* BinaryExpression */, 27 /* CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -19408,44 +20123,44 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 205 /* FunctionExpression */ || kind === 206 /* ArrowFunction */) { + if (kind === 208 /* FunctionExpression */ || kind === 209 /* ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 197 /* ObjectLiteralExpression */ || leftmostExpressionKind === 205 /* FunctionExpression */) { + if (leftmostExpressionKind === 200 /* ObjectLiteralExpression */ || leftmostExpressionKind === 208 /* FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 197 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 200 /* ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 183 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; + return member.kind === 184 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 181 /* UnionType */: - case 182 /* IntersectionType */: - case 173 /* FunctionType */: - case 174 /* ConstructorType */: + case 182 /* UnionType */: + case 183 /* IntersectionType */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 175 /* TypeQuery */: - case 187 /* TypeOperator */: - case 184 /* InferType */: + case 176 /* TypeQuery */: + case 188 /* TypeOperator */: + case 185 /* InferType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -19549,11 +20264,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 194 /* ArrayBindingPattern */: - case 196 /* ArrayLiteralExpression */: + case 197 /* ArrayBindingPattern */: + case 199 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 193 /* ObjectBindingPattern */: - case 197 /* ObjectLiteralExpression */: + case 196 /* ObjectBindingPattern */: + case 200 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -19681,6 +20396,8 @@ var ts; updateConstructSignature: updateConstructSignature, createIndexSignature: createIndexSignature, updateIndexSignature: updateIndexSignature, + createTemplateLiteralTypeSpan: createTemplateLiteralTypeSpan, + updateTemplateLiteralTypeSpan: updateTemplateLiteralTypeSpan, createKeywordTypeNode: createKeywordTypeNode, createTypePredicateNode: createTypePredicateNode, updateTypePredicateNode: updateTypePredicateNode, @@ -19725,6 +20442,8 @@ var ts; updateMappedTypeNode: updateMappedTypeNode, createLiteralTypeNode: createLiteralTypeNode, updateLiteralTypeNode: updateLiteralTypeNode, + createTemplateLiteralType: createTemplateLiteralType, + updateTemplateLiteralType: updateTemplateLiteralType, createObjectBindingPattern: createObjectBindingPattern, updateObjectBindingPattern: updateObjectBindingPattern, createArrayBindingPattern: createArrayBindingPattern, @@ -19890,18 +20609,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(299 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(300 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(302 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(302 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(301 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(301 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(303 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(303 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(305 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(305 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303 /* JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304 /* JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305 /* JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305 /* JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307 /* JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307 /* JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -19924,29 +20643,33 @@ var ts; updateJSDocAugmentsTag: updateJSDocAugmentsTag, createJSDocImplementsTag: createJSDocImplementsTag, updateJSDocImplementsTag: updateJSDocImplementsTag, + createJSDocSeeTag: createJSDocSeeTag, + updateJSDocSeeTag: updateJSDocSeeTag, + createJSDocNameReference: createJSDocNameReference, + updateJSDocNameReference: updateJSDocNameReference, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(325 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(325 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(323 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(323 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(324 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(324 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(321 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(321 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(313 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(313 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(315 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(315 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(316 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(316 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(317 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(317 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(318 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(318 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(319 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(319 /* JSDocReadonlyTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(314 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(314 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329 /* JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329 /* JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327 /* JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327 /* JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328 /* JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328 /* JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325 /* JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325 /* JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317 /* JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317 /* JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319 /* JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319 /* JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320 /* JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320 /* JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321 /* JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321 /* JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322 /* JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322 /* JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323 /* JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323 /* JSDocReadonlyTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318 /* JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318 /* JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocComment: createJSDocComment, @@ -20091,6 +20814,7 @@ var ts; if (elements.transformFlags === undefined) { aggregateChildrenFlags(elements); } + ts.Debug.attachNodeArrayDebugInfo(elements); return elements; } // Since the element list of a node array is typically created by starting with an empty array and @@ -20101,6 +20825,7 @@ var ts; ts.setTextRangePosEnd(array, -1, -1); array.hasTrailingComma = !!hasTrailingComma; aggregateChildrenFlags(array); + ts.Debug.attachNodeArrayDebugInfo(array); return array; } function createBaseNode(kind) { @@ -20130,11 +20855,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 162 /* PropertyDeclaration */: - case 285 /* PropertyAssignment */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 163 /* PropertyDeclaration */: + case 288 /* PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -20362,7 +21087,7 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 155 /* LastToken */, "Invalid token"); + ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 156 /* LastToken */, "Invalid token"); ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); ts.Debug.assert(token !== 78 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); @@ -20378,21 +21103,21 @@ var ts; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: - case 141 /* ReadonlyKeyword */: + case 142 /* ReadonlyKeyword */: case 125 /* AbstractKeyword */: case 133 /* DeclareKeyword */: case 84 /* ConstKeyword */: case 128 /* AnyKeyword */: - case 143 /* NumberKeyword */: - case 154 /* BigIntKeyword */: - case 140 /* NeverKeyword */: - case 144 /* ObjectKeyword */: - case 146 /* StringKeyword */: + case 144 /* NumberKeyword */: + case 155 /* BigIntKeyword */: + case 141 /* NeverKeyword */: + case 145 /* ObjectKeyword */: + case 147 /* StringKeyword */: case 131 /* BooleanKeyword */: - case 147 /* SymbolKeyword */: + case 148 /* SymbolKeyword */: case 113 /* VoidKeyword */: - case 151 /* UnknownKeyword */: - case 149 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 152 /* UnknownKeyword */: + case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. transformFlags = 1 /* ContainsTypeScript */; break; case 123 /* StaticKeyword */: @@ -20470,7 +21195,7 @@ var ts; result.push(createModifier(123 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(141 /* ReadonlyKeyword */)); + result.push(createModifier(142 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { result.push(createModifier(129 /* AsyncKeyword */)); @@ -20482,7 +21207,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(156 /* QualifiedName */); + var node = createBaseNode(157 /* QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -20499,7 +21224,7 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(157 /* ComputedPropertyName */); + var node = createBaseNode(158 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -20518,7 +21243,7 @@ var ts; // // @api function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(158 /* TypeParameter */, + var node = createBaseNamedDeclaration(159 /* TypeParameter */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.constraint = constraint; @@ -20536,7 +21261,7 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(159 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(160 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -20569,7 +21294,7 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(160 /* Decorator */); + var node = createBaseNode(161 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -20588,7 +21313,7 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(161 /* PropertySignature */, + var node = createBaseNamedDeclaration(162 /* PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; @@ -20606,7 +21331,7 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(162 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(163 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= @@ -20635,7 +21360,7 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(163 /* MethodSignature */, + var node = createBaseSignatureDeclaration(164 /* MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1 /* ContainsTypeScript */; @@ -20654,7 +21379,7 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(164 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(165 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= @@ -20693,7 +21418,7 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(165 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(166 /* Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); @@ -20711,7 +21436,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(166 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(167 /* GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -20727,7 +21452,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(167 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(168 /* SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -20743,7 +21468,7 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* CallSignature */, + var node = createBaseSignatureDeclaration(169 /* CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -20760,7 +21485,7 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(169 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(170 /* ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -20777,7 +21502,7 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(170 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(171 /* IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -20792,6 +21517,21 @@ var ts; ? updateBaseSignatureDeclaration(createIndexSignature(decorators, modifiers, parameters, type), node) : node; } + // @api + function createTemplateLiteralTypeSpan(type, literal) { + var node = createBaseNode(194 /* TemplateLiteralTypeSpan */); + node.type = type; + node.literal = literal; + node.transformFlags = 1 /* ContainsTypeScript */; + return node; + } + // @api + function updateTemplateLiteralTypeSpan(node, type, literal) { + return node.type !== type + || node.literal !== literal + ? update(createTemplateLiteralTypeSpan(type, literal), node) + : node; + } // // Types // @@ -20801,7 +21541,7 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(171 /* TypePredicate */); + var node = createBaseNode(172 /* TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -20818,7 +21558,7 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(172 /* TypeReference */); + var node = createBaseNode(173 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1 /* ContainsTypeScript */; @@ -20833,7 +21573,7 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(173 /* FunctionType */, + var node = createBaseSignatureDeclaration(174 /* FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -20850,7 +21590,7 @@ var ts; } // @api function createConstructorTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* ConstructorType */, + var node = createBaseSignatureDeclaration(175 /* ConstructorType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -20867,7 +21607,7 @@ var ts; } // @api function createTypeQueryNode(exprName) { - var node = createBaseNode(175 /* TypeQuery */); + var node = createBaseNode(176 /* TypeQuery */); node.exprName = exprName; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -20880,7 +21620,7 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(176 /* TypeLiteral */); + var node = createBaseNode(177 /* TypeLiteral */); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -20893,7 +21633,7 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(177 /* ArrayType */); + var node = createBaseNode(178 /* ArrayType */); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -20906,7 +21646,7 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(178 /* TupleType */); + var node = createBaseNode(179 /* TupleType */); node.elements = createNodeArray(elements); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -20919,7 +21659,7 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(191 /* NamedTupleMember */); + var node = createBaseNode(192 /* NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -20938,7 +21678,7 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(179 /* OptionalType */); + var node = createBaseNode(180 /* OptionalType */); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -20951,7 +21691,7 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(180 /* RestType */); + var node = createBaseNode(181 /* RestType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -20975,7 +21715,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(181 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(182 /* UnionType */, types); } // @api function updateUnionTypeNode(node, types) { @@ -20983,7 +21723,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(182 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(183 /* IntersectionType */, types); } // @api function updateIntersectionTypeNode(node, types) { @@ -20991,7 +21731,7 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(183 /* ConditionalType */); + var node = createBaseNode(184 /* ConditionalType */); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -21010,7 +21750,7 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(184 /* InferType */); + var node = createBaseNode(185 /* InferType */); node.typeParameter = typeParameter; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21022,9 +21762,24 @@ var ts; : node; } // @api + function createTemplateLiteralType(head, templateSpans) { + var node = createBaseNode(193 /* TemplateLiteralType */); + node.head = head; + node.templateSpans = createNodeArray(templateSpans); + node.transformFlags = 1 /* ContainsTypeScript */; + return node; + } + // @api + function updateTemplateLiteralType(node, head, templateSpans) { + return node.head !== head + || node.templateSpans !== templateSpans + ? update(createTemplateLiteralType(head, templateSpans), node) + : node; + } + // @api function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(192 /* ImportType */); + var node = createBaseNode(195 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -21044,7 +21799,7 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(185 /* ParenthesizedType */); + var node = createBaseNode(186 /* ParenthesizedType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21057,13 +21812,13 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(186 /* ThisType */); + var node = createBaseNode(187 /* ThisType */); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(187 /* TypeOperator */); + var node = createBaseNode(188 /* TypeOperator */); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21077,7 +21832,7 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(188 /* IndexedAccessType */); + var node = createBaseNode(189 /* IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21091,27 +21846,29 @@ var ts; : node; } // @api - function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createBaseNode(189 /* MappedType */); + function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { + var node = createBaseNode(190 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; + node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api - function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) { + function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type) { return node.readonlyToken !== readonlyToken || node.typeParameter !== typeParameter + || node.nameType !== nameType || node.questionToken !== questionToken || node.type !== type - ? update(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) + ? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), node) : node; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(190 /* LiteralType */); + var node = createBaseNode(191 /* LiteralType */); node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21127,7 +21884,7 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(193 /* ObjectBindingPattern */); + var node = createBaseNode(196 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | @@ -21148,7 +21905,7 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(194 /* ArrayBindingPattern */); + var node = createBaseNode(197 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | @@ -21164,7 +21921,7 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(195 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(198 /* BindingElement */, /*decorators*/ undefined, /*modifiers*/ undefined, name, initializer); node.propertyName = asName(propertyName); @@ -21200,7 +21957,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(196 /* ArrayLiteralExpression */); + var node = createBaseExpression(199 /* ArrayLiteralExpression */); node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements)); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.elements); @@ -21214,7 +21971,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(197 /* ObjectLiteralExpression */); + var node = createBaseExpression(200 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -21228,7 +21985,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(198 /* PropertyAccessExpression */); + var node = createBaseExpression(201 /* PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -21257,7 +22014,7 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(198 /* PropertyAccessExpression */); + var node = createBaseExpression(201 /* PropertyAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -21284,7 +22041,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(199 /* ElementAccessExpression */); + var node = createBaseExpression(202 /* ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -21311,7 +22068,7 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(199 /* ElementAccessExpression */); + var node = createBaseExpression(202 /* ElementAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -21336,7 +22093,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(200 /* CallExpression */); + var node = createBaseExpression(203 /* CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -21368,7 +22125,7 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(200 /* CallExpression */); + var node = createBaseExpression(203 /* CallExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -21400,7 +22157,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(201 /* NewExpression */); + var node = createBaseExpression(204 /* NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -21424,7 +22181,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(202 /* TaggedTemplateExpression */); + var node = createBaseExpression(205 /* TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -21451,7 +22208,7 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(203 /* TypeAssertionExpression */); + var node = createBaseExpression(206 /* TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -21469,7 +22226,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(204 /* ParenthesizedExpression */); + var node = createBaseExpression(207 /* ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -21482,7 +22239,7 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(205 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(208 /* FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); @@ -21516,7 +22273,7 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(206 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(209 /* ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); @@ -21541,7 +22298,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(207 /* DeleteExpression */); + var node = createBaseExpression(210 /* DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -21554,7 +22311,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(208 /* TypeOfExpression */); + var node = createBaseExpression(211 /* TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -21567,7 +22324,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(209 /* VoidExpression */); + var node = createBaseExpression(212 /* VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -21580,7 +22337,7 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(210 /* AwaitExpression */); + var node = createBaseExpression(213 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -21597,7 +22354,7 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(211 /* PrefixUnaryExpression */); + var node = createBaseExpression(214 /* PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -21611,7 +22368,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(212 /* PostfixUnaryExpression */); + var node = createBaseExpression(215 /* PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags = propagateChildFlags(node.operand); @@ -21625,7 +22382,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(213 /* BinaryExpression */); + var node = createBaseExpression(216 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -21643,12 +22400,14 @@ var ts; node.transformFlags |= 256 /* ContainsES2015 */ | 32 /* ContainsES2018 */ | - 1024 /* ContainsDestructuringAssignment */; + 1024 /* ContainsDestructuringAssignment */ | + propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= 256 /* ContainsES2015 */ | - 1024 /* ContainsDestructuringAssignment */; + 1024 /* ContainsDestructuringAssignment */ | + propagateAssignmentPatternFlags(node.left); } } else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 66 /* AsteriskAsteriskEqualsToken */) { @@ -21659,6 +22418,29 @@ var ts; } return node; } + function propagateAssignmentPatternFlags(node) { + if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) + return 16384 /* ContainsObjectRestOrSpread */; + if (node.transformFlags & 32 /* ContainsES2018 */) { + // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' + // will not be correctly interpreted by the ES2018 transformer + for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { + var element = _a[_i]; + var target = ts.getTargetOfBindingOrAssignmentElement(element); + if (target && ts.isAssignmentPattern(target)) { + if (target.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + return 16384 /* ContainsObjectRestOrSpread */; + } + if (target.transformFlags & 32 /* ContainsES2018 */) { + var flags_1 = propagateAssignmentPatternFlags(target); + if (flags_1) + return flags_1; + } + } + } + } + return 0 /* None */; + } // @api function updateBinaryExpression(node, left, operator, right) { return node.left !== left @@ -21669,7 +22451,7 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(214 /* ConditionalExpression */); + var node = createBaseExpression(217 /* ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -21695,7 +22477,7 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(215 /* TemplateExpression */); + var node = createBaseExpression(218 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= @@ -21765,7 +22547,7 @@ var ts; // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(216 /* YieldExpression */); + var node = createBaseExpression(219 /* YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= @@ -21785,7 +22567,7 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(217 /* SpreadElement */); + var node = createBaseExpression(220 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -21801,7 +22583,7 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(218 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(221 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); node.transformFlags |= 256 /* ContainsES2015 */; return node; } @@ -21818,11 +22600,11 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(219 /* OmittedExpression */); + return createBaseExpression(222 /* OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(220 /* ExpressionWithTypeArguments */); + var node = createBaseNode(223 /* ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= @@ -21840,7 +22622,7 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(221 /* AsExpression */); + var node = createBaseExpression(224 /* AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= @@ -21858,7 +22640,7 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(222 /* NonNullExpression */); + var node = createBaseExpression(225 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -21876,7 +22658,7 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(222 /* NonNullExpression */); + var node = createBaseExpression(225 /* NonNullExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -21893,7 +22675,7 @@ var ts; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(223 /* MetaProperty */); + var node = createBaseExpression(226 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); @@ -21920,7 +22702,7 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(225 /* TemplateSpan */); + var node = createBaseNode(228 /* TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= @@ -21938,7 +22720,7 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(226 /* SemicolonClassElement */); + var node = createBaseNode(229 /* SemicolonClassElement */); node.transformFlags |= 256 /* ContainsES2015 */; return node; } @@ -21947,7 +22729,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(227 /* Block */); + var node = createBaseNode(230 /* Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -21961,7 +22743,7 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(229 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(232 /* VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -21979,11 +22761,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(228 /* EmptyStatement */); + return createBaseNode(231 /* EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(230 /* ExpressionStatement */); + var node = createBaseNode(233 /* ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -21996,7 +22778,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(231 /* IfStatement */); + var node = createBaseNode(234 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -22016,7 +22798,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(232 /* DoStatement */); + var node = createBaseNode(235 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -22033,7 +22815,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(233 /* WhileStatement */); + var node = createBaseNode(236 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -22050,7 +22832,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(234 /* ForStatement */); + var node = createBaseNode(237 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -22073,7 +22855,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(235 /* ForInStatement */); + var node = createBaseNode(238 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -22093,7 +22875,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(236 /* ForOfStatement */); + var node = createBaseNode(239 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -22119,7 +22901,7 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(237 /* ContinueStatement */); + var node = createBaseNode(240 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | @@ -22134,7 +22916,7 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(238 /* BreakStatement */); + var node = createBaseNode(241 /* BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | @@ -22149,7 +22931,7 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(239 /* ReturnStatement */); + var node = createBaseNode(242 /* ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= @@ -22166,7 +22948,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(240 /* WithStatement */); + var node = createBaseNode(243 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -22183,7 +22965,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(241 /* SwitchStatement */); + var node = createBaseNode(244 /* SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -22200,7 +22982,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(242 /* LabeledStatement */); + var node = createBaseNode(245 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -22217,7 +22999,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(243 /* ThrowStatement */); + var node = createBaseNode(246 /* ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22230,7 +23012,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(244 /* TryStatement */); + var node = createBaseNode(247 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -22250,11 +23032,11 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(245 /* DebuggerStatement */); + return createBaseNode(248 /* DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(246 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(249 /* VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; @@ -22276,7 +23058,7 @@ var ts; // @api function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(247 /* VariableDeclarationList */); + var node = createBaseNode(250 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= @@ -22297,7 +23079,7 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(248 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(251 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; @@ -22335,7 +23117,7 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(249 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(252 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } @@ -22360,7 +23142,7 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(250 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(253 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22378,7 +23160,7 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(251 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(254 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22395,7 +23177,7 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(252 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(255 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | @@ -22415,7 +23197,7 @@ var ts; // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(253 /* ModuleDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(256 /* ModuleDeclaration */, decorators, modifiers); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.name = name; node.body = body; @@ -22442,7 +23224,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(254 /* ModuleBlock */); + var node = createBaseNode(257 /* ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -22455,7 +23237,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(255 /* CaseBlock */); + var node = createBaseNode(258 /* CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -22468,7 +23250,7 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(256 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(259 /* NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22482,7 +23264,7 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createBaseNamedDeclaration(257 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(260 /* ImportEqualsDeclaration */, decorators, modifiers, name); node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) @@ -22501,7 +23283,7 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(258 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(261 /* ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= @@ -22521,7 +23303,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(259 /* ImportClause */); + var node = createBaseNode(262 /* ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -22544,7 +23326,7 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(260 /* NamespaceImport */); + var node = createBaseNode(263 /* NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -22558,7 +23340,7 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(266 /* NamespaceExport */); + var node = createBaseNode(269 /* NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | @@ -22574,7 +23356,7 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(261 /* NamedImports */); + var node = createBaseNode(264 /* NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -22588,7 +23370,7 @@ var ts; } // @api function createImportSpecifier(propertyName, name) { - var node = createBaseNode(262 /* ImportSpecifier */); + var node = createBaseNode(265 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; node.transformFlags |= @@ -22606,7 +23388,7 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(263 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(266 /* ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals ? parenthesizerRules().parenthesizeRightSideOfBinary(62 /* EqualsToken */, /*leftSide*/ undefined, expression) @@ -22625,7 +23407,7 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(264 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(267 /* ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; @@ -22647,7 +23429,7 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(265 /* NamedExports */); + var node = createBaseNode(268 /* NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -22661,7 +23443,7 @@ var ts; } // @api function createExportSpecifier(propertyName, name) { - var node = createBaseNode(267 /* ExportSpecifier */); + var node = createBaseNode(270 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= @@ -22679,7 +23461,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(268 /* MissingDeclaration */, + var node = createBaseDeclaration(271 /* MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -22689,7 +23471,7 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(269 /* ExternalModuleReference */); + var node = createBaseNode(272 /* ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -22734,7 +23516,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(304 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(308 /* JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -22751,7 +23533,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(308 /* JSDocTypeLiteral */); + var node = createBaseNode(312 /* JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -22765,7 +23547,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(298 /* JSDocTypeExpression */); + var node = createBaseNode(301 /* JSDocTypeExpression */); node.type = type; return node; } @@ -22777,7 +23559,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(309 /* JSDocSignature */); + var node = createBaseNode(313 /* JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -22806,7 +23588,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(326 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(330 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -22823,7 +23605,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(331 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -22841,7 +23623,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(322 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(326 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -22862,7 +23644,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(328 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(333 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -22883,7 +23665,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(320 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(324 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -22901,7 +23683,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(311 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(315 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -22916,11 +23698,37 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(312 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(316 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api + function createJSDocSeeTag(tagName, name, comment) { + var node = createBaseJSDocTag(332 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + node.name = name; + return node; + } + // @api + function updateJSDocSeeTag(node, tagName, name, comment) { + return node.tagName !== tagName + || node.name !== name + || node.comment !== comment + ? update(createJSDocSeeTag(tagName, name, comment), node) + : node; + } + // @api + function createJSDocNameReference(name) { + var node = createBaseNode(302 /* JSDocNameReference */); + node.name = name; + return node; + } + // @api + function updateJSDocNameReference(node, name) { + return node.name !== name + ? update(createJSDocNameReference(name), node) + : node; + } + // @api function updateJSDocImplementsTag(node, tagName, className, comment) { if (tagName === void 0) { tagName = getDefaultTagName(node); } return node.tagName !== tagName @@ -22981,7 +23789,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(310 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(314 /* JSDocTag */, tagName, comment); return node; } // @api @@ -22993,7 +23801,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(307 /* JSDocComment */); + var node = createBaseNode(311 /* JSDocComment */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -23010,7 +23818,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(270 /* JsxElement */); + var node = createBaseNode(273 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -23031,7 +23839,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(271 /* JsxSelfClosingElement */); + var node = createBaseNode(274 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -23055,7 +23863,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(272 /* JsxOpeningElement */); + var node = createBaseNode(275 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -23079,7 +23887,7 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(273 /* JsxClosingElement */); + var node = createBaseNode(276 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -23094,7 +23902,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(274 /* JsxFragment */); + var node = createBaseNode(277 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -23130,19 +23938,19 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(275 /* JsxOpeningFragment */); + var node = createBaseNode(278 /* JsxOpeningFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(276 /* JsxClosingFragment */); + var node = createBaseNode(279 /* JsxClosingFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(277 /* JsxAttribute */); + var node = createBaseNode(280 /* JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -23160,7 +23968,7 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(278 /* JsxAttributes */); + var node = createBaseNode(281 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -23175,7 +23983,7 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(279 /* JsxSpreadAttribute */); + var node = createBaseNode(282 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -23190,7 +23998,7 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(280 /* JsxExpression */); + var node = createBaseNode(283 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -23210,7 +24018,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(281 /* CaseClause */); + var node = createBaseNode(284 /* CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -23227,7 +24035,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(282 /* DefaultClause */); + var node = createBaseNode(285 /* DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -23240,7 +24048,7 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(283 /* HeritageClause */); + var node = createBaseNode(286 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); @@ -23264,7 +24072,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(284 /* CatchClause */); + var node = createBaseNode(287 /* CatchClause */); variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, /*type*/ undefined, @@ -23290,7 +24098,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(285 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(288 /* PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -23320,7 +24128,7 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(286 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(289 /* ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); @@ -23352,7 +24160,7 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(287 /* SpreadAssignment */); + var node = createBaseNode(290 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -23371,7 +24179,7 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(288 /* EnumMember */); + var node = createBaseNode(291 /* EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -23392,7 +24200,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(294 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -23409,7 +24217,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(294 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -23447,7 +24255,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(295 /* Bundle */); + var node = createBaseNode(298 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -23462,7 +24270,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(296 /* UnparsedSource */); + var node = createBaseNode(299 /* UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -23480,28 +24288,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(289 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(292 /* UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(290 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(293 /* UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 292 /* UnparsedInternalText */ : 291 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 295 /* UnparsedInternalText */ : 294 /* UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(293 /* UnparsedSyntheticReference */); + var node = createBaseNode(296 /* UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(297 /* InputFiles */); + var node = createBaseNode(300 /* InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -23512,7 +24320,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(224 /* SyntheticExpression */); + var node = createBaseNode(227 /* SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -23520,7 +24328,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(329 /* SyntaxList */); + var node = createBaseNode(334 /* SyntaxList */); node._children = children; return node; } @@ -23535,7 +24343,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(330 /* NotEmittedStatement */); + var node = createBaseNode(335 /* NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -23549,7 +24357,7 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(331 /* PartiallyEmittedExpression */); + var node = createBaseNode(336 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= @@ -23577,7 +24385,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(332 /* CommaListExpression */); + var node = createBaseNode(337 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -23594,7 +24402,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(334 /* EndOfDeclarationMarker */); + var node = createBaseNode(339 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -23605,14 +24413,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(333 /* MergeDeclarationMarker */); + var node = createBaseNode(338 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(335 /* SyntheticReferenceExpression */); + var node = createBaseNode(340 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -23634,7 +24442,7 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(294 /* SourceFile */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297 /* SourceFile */) : ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78 /* Identifier */) : ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : @@ -23741,11 +24549,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 204 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 203 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 221 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 222 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 331 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 207 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 206 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 224 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 225 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 336 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -23799,13 +24607,13 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -24208,23 +25016,23 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 325 /* JSDocTypeTag */: return "type"; - case 323 /* JSDocReturnTag */: return "returns"; - case 324 /* JSDocThisTag */: return "this"; - case 321 /* JSDocEnumTag */: return "enum"; - case 313 /* JSDocAuthorTag */: return "author"; - case 315 /* JSDocClassTag */: return "class"; - case 316 /* JSDocPublicTag */: return "public"; - case 317 /* JSDocPrivateTag */: return "private"; - case 318 /* JSDocProtectedTag */: return "protected"; - case 319 /* JSDocReadonlyTag */: return "readonly"; - case 326 /* JSDocTemplateTag */: return "template"; - case 327 /* JSDocTypedefTag */: return "typedef"; - case 322 /* JSDocParameterTag */: return "param"; - case 328 /* JSDocPropertyTag */: return "prop"; - case 320 /* JSDocCallbackTag */: return "callback"; - case 311 /* JSDocAugmentsTag */: return "augments"; - case 312 /* JSDocImplementsTag */: return "implements"; + case 329 /* JSDocTypeTag */: return "type"; + case 327 /* JSDocReturnTag */: return "returns"; + case 328 /* JSDocThisTag */: return "this"; + case 325 /* JSDocEnumTag */: return "enum"; + case 317 /* JSDocAuthorTag */: return "author"; + case 319 /* JSDocClassTag */: return "class"; + case 320 /* JSDocPublicTag */: return "public"; + case 321 /* JSDocPrivateTag */: return "private"; + case 322 /* JSDocProtectedTag */: return "protected"; + case 323 /* JSDocReadonlyTag */: return "readonly"; + case 330 /* JSDocTemplateTag */: return "template"; + case 331 /* JSDocTypedefTag */: return "typedef"; + case 326 /* JSDocParameterTag */: return "param"; + case 333 /* JSDocPropertyTag */: return "prop"; + case 324 /* JSDocCallbackTag */: return "callback"; + case 315 /* JSDocAugmentsTag */: return "augments"; + case 316 /* JSDocImplementsTag */: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -24304,69 +25112,69 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 171 /* FirstTypeNode */ && kind <= 192 /* LastTypeNode */) { + if (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 200 /* CallExpression */: - case 201 /* NewExpression */: - case 196 /* ArrayLiteralExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: + case 199 /* ArrayLiteralExpression */: return 536879104 /* ArrayLiteralOrCallOrNewExcludes */; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return 546379776 /* ModuleExcludes */; - case 159 /* Parameter */: + case 160 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return 547309568 /* ArrowFunctionExcludes */; - case 205 /* FunctionExpression */: - case 248 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: return 547313664 /* FunctionExcludes */; - case 247 /* VariableDeclarationList */: + case 250 /* VariableDeclarationList */: return 537018368 /* VariableDeclarationListExcludes */; - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: return 536905728 /* ClassExcludes */; - case 165 /* Constructor */: + case 166 /* Constructor */: return 547311616 /* ConstructorExcludes */; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return 536875008 /* PropertyExcludes */; - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return 538923008 /* MethodOrAccessorExcludes */; case 128 /* AnyKeyword */: - case 143 /* NumberKeyword */: - case 154 /* BigIntKeyword */: - case 140 /* NeverKeyword */: - case 146 /* StringKeyword */: - case 144 /* ObjectKeyword */: + case 144 /* NumberKeyword */: + case 155 /* BigIntKeyword */: + case 141 /* NeverKeyword */: + case 147 /* StringKeyword */: + case 145 /* ObjectKeyword */: case 131 /* BooleanKeyword */: - case 147 /* SymbolKeyword */: + case 148 /* SymbolKeyword */: case 113 /* VoidKeyword */: - case 158 /* TypeParameter */: - case 161 /* PropertySignature */: - case 163 /* MethodSignature */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 170 /* IndexSignature */: - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: + case 159 /* TypeParameter */: + case 162 /* PropertySignature */: + case 164 /* MethodSignature */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 171 /* IndexSignature */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return 536922112 /* ObjectLiteralExcludes */; - case 284 /* CatchClause */: + case 287 /* CatchClause */: return 536887296 /* CatchClauseExcludes */; - case 193 /* ObjectBindingPattern */: - case 194 /* ArrayBindingPattern */: + case 196 /* ObjectBindingPattern */: + case 197 /* ArrayBindingPattern */: return 536879104 /* BindingPatternExcludes */; - case 203 /* TypeAssertionExpression */: - case 221 /* AsExpression */: - case 331 /* PartiallyEmittedExpression */: - case 204 /* ParenthesizedExpression */: + case 206 /* TypeAssertionExpression */: + case 224 /* AsExpression */: + case 336 /* PartiallyEmittedExpression */: + case 207 /* ParenthesizedExpression */: case 105 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -24665,7 +25473,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 294 /* SourceFile */) { + if (node.kind === 297 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -25522,11 +26330,11 @@ var ts; ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 156 /* QualifiedName */; + return node.kind === 157 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 157 /* ComputedPropertyName */; + return node.kind === 158 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isPrivateIdentifier(node) { @@ -25561,572 +26369,580 @@ var ts; ts.isExclamationToken = isExclamationToken; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 158 /* TypeParameter */; + return node.kind === 159 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 159 /* Parameter */; + return node.kind === 160 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 160 /* Decorator */; + return node.kind === 161 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 161 /* PropertySignature */; + return node.kind === 162 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 162 /* PropertyDeclaration */; + return node.kind === 163 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 163 /* MethodSignature */; + return node.kind === 164 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 164 /* MethodDeclaration */; + return node.kind === 165 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 165 /* Constructor */; + return node.kind === 166 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 166 /* GetAccessor */; + return node.kind === 167 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 167 /* SetAccessor */; + return node.kind === 168 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 168 /* CallSignature */; + return node.kind === 169 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 169 /* ConstructSignature */; + return node.kind === 170 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 170 /* IndexSignature */; + return node.kind === 171 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 171 /* TypePredicate */; + return node.kind === 172 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 172 /* TypeReference */; + return node.kind === 173 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 173 /* FunctionType */; + return node.kind === 174 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 174 /* ConstructorType */; + return node.kind === 175 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 175 /* TypeQuery */; + return node.kind === 176 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 176 /* TypeLiteral */; + return node.kind === 177 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 177 /* ArrayType */; + return node.kind === 178 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 178 /* TupleType */; + return node.kind === 179 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 191 /* NamedTupleMember */; + return node.kind === 192 /* NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 179 /* OptionalType */; + return node.kind === 180 /* OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 180 /* RestType */; + return node.kind === 181 /* RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 181 /* UnionType */; + return node.kind === 182 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 182 /* IntersectionType */; + return node.kind === 183 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 183 /* ConditionalType */; + return node.kind === 184 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 184 /* InferType */; + return node.kind === 185 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 185 /* ParenthesizedType */; + return node.kind === 186 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 186 /* ThisType */; + return node.kind === 187 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 187 /* TypeOperator */; + return node.kind === 188 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 188 /* IndexedAccessType */; + return node.kind === 189 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 189 /* MappedType */; + return node.kind === 190 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 190 /* LiteralType */; + return node.kind === 191 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 192 /* ImportType */; + return node.kind === 195 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; + function isTemplateLiteralTypeSpan(node) { + return node.kind === 194 /* TemplateLiteralTypeSpan */; + } + ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; + function isTemplateLiteralTypeNode(node) { + return node.kind === 193 /* TemplateLiteralType */; + } + ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 193 /* ObjectBindingPattern */; + return node.kind === 196 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 194 /* ArrayBindingPattern */; + return node.kind === 197 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 195 /* BindingElement */; + return node.kind === 198 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 196 /* ArrayLiteralExpression */; + return node.kind === 199 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 197 /* ObjectLiteralExpression */; + return node.kind === 200 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 198 /* PropertyAccessExpression */; + return node.kind === 201 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 199 /* ElementAccessExpression */; + return node.kind === 202 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 200 /* CallExpression */; + return node.kind === 203 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 201 /* NewExpression */; + return node.kind === 204 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 202 /* TaggedTemplateExpression */; + return node.kind === 205 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 203 /* TypeAssertionExpression */; + return node.kind === 206 /* TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 204 /* ParenthesizedExpression */; + return node.kind === 207 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 205 /* FunctionExpression */; + return node.kind === 208 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 206 /* ArrowFunction */; + return node.kind === 209 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 207 /* DeleteExpression */; + return node.kind === 210 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 208 /* TypeOfExpression */; + return node.kind === 211 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 209 /* VoidExpression */; + return node.kind === 212 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 210 /* AwaitExpression */; + return node.kind === 213 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 211 /* PrefixUnaryExpression */; + return node.kind === 214 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 212 /* PostfixUnaryExpression */; + return node.kind === 215 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 213 /* BinaryExpression */; + return node.kind === 216 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 214 /* ConditionalExpression */; + return node.kind === 217 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 215 /* TemplateExpression */; + return node.kind === 218 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 216 /* YieldExpression */; + return node.kind === 219 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 217 /* SpreadElement */; + return node.kind === 220 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 218 /* ClassExpression */; + return node.kind === 221 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 219 /* OmittedExpression */; + return node.kind === 222 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 220 /* ExpressionWithTypeArguments */; + return node.kind === 223 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 221 /* AsExpression */; + return node.kind === 224 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 222 /* NonNullExpression */; + return node.kind === 225 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 223 /* MetaProperty */; + return node.kind === 226 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 224 /* SyntheticExpression */; + return node.kind === 227 /* SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 331 /* PartiallyEmittedExpression */; + return node.kind === 336 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 332 /* CommaListExpression */; + return node.kind === 337 /* CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 225 /* TemplateSpan */; + return node.kind === 228 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 226 /* SemicolonClassElement */; + return node.kind === 229 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 227 /* Block */; + return node.kind === 230 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 229 /* VariableStatement */; + return node.kind === 232 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 228 /* EmptyStatement */; + return node.kind === 231 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 230 /* ExpressionStatement */; + return node.kind === 233 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 231 /* IfStatement */; + return node.kind === 234 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 232 /* DoStatement */; + return node.kind === 235 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 233 /* WhileStatement */; + return node.kind === 236 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 234 /* ForStatement */; + return node.kind === 237 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 235 /* ForInStatement */; + return node.kind === 238 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 236 /* ForOfStatement */; + return node.kind === 239 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 237 /* ContinueStatement */; + return node.kind === 240 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 238 /* BreakStatement */; + return node.kind === 241 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 239 /* ReturnStatement */; + return node.kind === 242 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 240 /* WithStatement */; + return node.kind === 243 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 241 /* SwitchStatement */; + return node.kind === 244 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 242 /* LabeledStatement */; + return node.kind === 245 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 243 /* ThrowStatement */; + return node.kind === 246 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 244 /* TryStatement */; + return node.kind === 247 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 245 /* DebuggerStatement */; + return node.kind === 248 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 246 /* VariableDeclaration */; + return node.kind === 249 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 247 /* VariableDeclarationList */; + return node.kind === 250 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 248 /* FunctionDeclaration */; + return node.kind === 251 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 249 /* ClassDeclaration */; + return node.kind === 252 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 250 /* InterfaceDeclaration */; + return node.kind === 253 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 251 /* TypeAliasDeclaration */; + return node.kind === 254 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 252 /* EnumDeclaration */; + return node.kind === 255 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 253 /* ModuleDeclaration */; + return node.kind === 256 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 254 /* ModuleBlock */; + return node.kind === 257 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 255 /* CaseBlock */; + return node.kind === 258 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 256 /* NamespaceExportDeclaration */; + return node.kind === 259 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 257 /* ImportEqualsDeclaration */; + return node.kind === 260 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 258 /* ImportDeclaration */; + return node.kind === 261 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 259 /* ImportClause */; + return node.kind === 262 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 260 /* NamespaceImport */; + return node.kind === 263 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 266 /* NamespaceExport */; + return node.kind === 269 /* NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 261 /* NamedImports */; + return node.kind === 264 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 262 /* ImportSpecifier */; + return node.kind === 265 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 263 /* ExportAssignment */; + return node.kind === 266 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 264 /* ExportDeclaration */; + return node.kind === 267 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 265 /* NamedExports */; + return node.kind === 268 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 267 /* ExportSpecifier */; + return node.kind === 270 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 268 /* MissingDeclaration */; + return node.kind === 271 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 330 /* NotEmittedStatement */; + return node.kind === 335 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 335 /* SyntheticReferenceExpression */; + return node.kind === 340 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 333 /* MergeDeclarationMarker */; + return node.kind === 338 /* MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 334 /* EndOfDeclarationMarker */; + return node.kind === 339 /* EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 269 /* ExternalModuleReference */; + return node.kind === 272 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 270 /* JsxElement */; + return node.kind === 273 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 271 /* JsxSelfClosingElement */; + return node.kind === 274 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 272 /* JsxOpeningElement */; + return node.kind === 275 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 273 /* JsxClosingElement */; + return node.kind === 276 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 274 /* JsxFragment */; + return node.kind === 277 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 275 /* JsxOpeningFragment */; + return node.kind === 278 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 276 /* JsxClosingFragment */; + return node.kind === 279 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 277 /* JsxAttribute */; + return node.kind === 280 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 278 /* JsxAttributes */; + return node.kind === 281 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 279 /* JsxSpreadAttribute */; + return node.kind === 282 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 280 /* JsxExpression */; + return node.kind === 283 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 281 /* CaseClause */; + return node.kind === 284 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 282 /* DefaultClause */; + return node.kind === 285 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 283 /* HeritageClause */; + return node.kind === 286 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 284 /* CatchClause */; + return node.kind === 287 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 285 /* PropertyAssignment */; + return node.kind === 288 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 286 /* ShorthandPropertyAssignment */; + return node.kind === 289 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 287 /* SpreadAssignment */; + return node.kind === 290 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 288 /* EnumMember */; + return node.kind === 291 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 290 /* UnparsedPrepend */; + return node.kind === 293 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -26134,148 +26950,152 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 294 /* SourceFile */; + return node.kind === 297 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 295 /* Bundle */; + return node.kind === 298 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 296 /* UnparsedSource */; + return node.kind === 299 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 298 /* JSDocTypeExpression */; + return node.kind === 301 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; + function isJSDocNameReference(node) { + return node.kind === 302 /* JSDocNameReference */; + } + ts.isJSDocNameReference = isJSDocNameReference; function isJSDocAllType(node) { - return node.kind === 299 /* JSDocAllType */; + return node.kind === 303 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 300 /* JSDocUnknownType */; + return node.kind === 304 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 301 /* JSDocNullableType */; + return node.kind === 305 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 302 /* JSDocNonNullableType */; + return node.kind === 306 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 303 /* JSDocOptionalType */; + return node.kind === 307 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 304 /* JSDocFunctionType */; + return node.kind === 308 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 305 /* JSDocVariadicType */; + return node.kind === 309 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 306 /* JSDocNamepathType */; + return node.kind === 310 /* JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 307 /* JSDocComment */; + return node.kind === 311 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 308 /* JSDocTypeLiteral */; + return node.kind === 312 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 309 /* JSDocSignature */; + return node.kind === 313 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 311 /* JSDocAugmentsTag */; + return node.kind === 315 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 313 /* JSDocAuthorTag */; + return node.kind === 317 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 315 /* JSDocClassTag */; + return node.kind === 319 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 320 /* JSDocCallbackTag */; + return node.kind === 324 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 316 /* JSDocPublicTag */; + return node.kind === 320 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 317 /* JSDocPrivateTag */; + return node.kind === 321 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 318 /* JSDocProtectedTag */; + return node.kind === 322 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 319 /* JSDocReadonlyTag */; + return node.kind === 323 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocDeprecatedTag(node) { - return node.kind === 314 /* JSDocDeprecatedTag */; + return node.kind === 318 /* JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocEnumTag(node) { - return node.kind === 321 /* JSDocEnumTag */; + return node.kind === 325 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 322 /* JSDocParameterTag */; + return node.kind === 326 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 323 /* JSDocReturnTag */; + return node.kind === 327 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 324 /* JSDocThisTag */; + return node.kind === 328 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 325 /* JSDocTypeTag */; + return node.kind === 329 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 326 /* JSDocTemplateTag */; + return node.kind === 330 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 327 /* JSDocTypedefTag */; + return node.kind === 331 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 310 /* JSDocTag */; + return node.kind === 314 /* JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 328 /* JSDocPropertyTag */; + return node.kind === 333 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 312 /* JSDocImplementsTag */; + return node.kind === 316 /* JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 329 /* SyntaxList */; + return n.kind === 334 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -26326,12 +27146,13 @@ var ts; createJsxFactoryExpressionFromEntityName(factory, jsxFactoryEntity, parent) : factory.createPropertyAccessExpression(createReactNamespace(reactNamespace, parent), "createElement"); } + ts.createJsxFactoryExpression = createJsxFactoryExpression; function createJsxFragmentFactoryExpression(factory, jsxFragmentFactoryEntity, reactNamespace, parent) { return jsxFragmentFactoryEntity ? createJsxFactoryExpressionFromEntityName(factory, jsxFragmentFactoryEntity, parent) : factory.createPropertyAccessExpression(createReactNamespace(reactNamespace, parent), "Fragment"); } - function createExpressionForJsxElement(factory, jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { + function createExpressionForJsxElement(factory, callee, tagName, props, children, location) { var argumentsList = [tagName]; if (props) { argumentsList.push(props); @@ -26351,7 +27172,7 @@ var ts; argumentsList.push(children[0]); } } - return ts.setTextRange(factory.createCallExpression(createJsxFactoryExpression(factory, jsxFactoryEntity, reactNamespace, parentElement), + return ts.setTextRange(factory.createCallExpression(callee, /*typeArguments*/ undefined, argumentsList), location); } ts.createExpressionForJsxElement = createExpressionForJsxElement; @@ -26473,14 +27294,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -26533,21 +27354,21 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 213 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 332 /* CommaListExpression */; + return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 337 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 203 /* TypeAssertionExpression */: - case 221 /* AsExpression */: + case 206 /* TypeAssertionExpression */: + case 224 /* AsExpression */: return (kinds & 2 /* TypeAssertions */) !== 0; - case 222 /* NonNullExpression */: + case 225 /* NonNullExpression */: return (kinds & 4 /* NonNullAssertions */) !== 0; - case 331 /* PartiallyEmittedExpression */: + case 336 /* PartiallyEmittedExpression */: return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -26664,14 +27485,14 @@ var ts; */ function getLocalNameForExternalImport(factory, node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !ts.isDefaultImport(node)) { + if (namespaceDeclaration && !ts.isDefaultImport(node) && !ts.isExportNamespaceAsDefaultDeclaration(node)) { var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 258 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 261 /* ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 264 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 267 /* ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -26790,7 +27611,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -26802,11 +27623,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 287 /* SpreadAssignment */: + case 290 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -26838,12 +27659,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 159 /* Parameter */: - case 195 /* BindingElement */: + case 160 /* Parameter */: + case 198 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 217 /* SpreadElement */: - case 287 /* SpreadAssignment */: + case 220 /* SpreadElement */: + case 290 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -26861,7 +27682,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 195 /* BindingElement */: + case 198 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -26876,7 +27697,7 @@ var ts; : propertyName; } break; - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -26891,7 +27712,7 @@ var ts; : propertyName; } break; - case 287 /* SpreadAssignment */: + case 290 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -26914,13 +27735,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 193 /* ObjectBindingPattern */: - case 194 /* ArrayBindingPattern */: - case 196 /* ArrayLiteralExpression */: + case 196 /* ObjectBindingPattern */: + case 197 /* ArrayBindingPattern */: + case 199 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -26941,29 +27762,29 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 159 /* Parameter */ - || kind === 161 /* PropertySignature */ - || kind === 162 /* PropertyDeclaration */ - || kind === 163 /* MethodSignature */ - || kind === 164 /* MethodDeclaration */ - || kind === 165 /* Constructor */ - || kind === 166 /* GetAccessor */ - || kind === 167 /* SetAccessor */ - || kind === 170 /* IndexSignature */ - || kind === 205 /* FunctionExpression */ - || kind === 206 /* ArrowFunction */ - || kind === 218 /* ClassExpression */ - || kind === 229 /* VariableStatement */ - || kind === 248 /* FunctionDeclaration */ - || kind === 249 /* ClassDeclaration */ - || kind === 250 /* InterfaceDeclaration */ - || kind === 251 /* TypeAliasDeclaration */ - || kind === 252 /* EnumDeclaration */ - || kind === 253 /* ModuleDeclaration */ - || kind === 257 /* ImportEqualsDeclaration */ - || kind === 258 /* ImportDeclaration */ - || kind === 263 /* ExportAssignment */ - || kind === 264 /* ExportDeclaration */; + return kind === 160 /* Parameter */ + || kind === 162 /* PropertySignature */ + || kind === 163 /* PropertyDeclaration */ + || kind === 164 /* MethodSignature */ + || kind === 165 /* MethodDeclaration */ + || kind === 166 /* Constructor */ + || kind === 167 /* GetAccessor */ + || kind === 168 /* SetAccessor */ + || kind === 171 /* IndexSignature */ + || kind === 208 /* FunctionExpression */ + || kind === 209 /* ArrowFunction */ + || kind === 221 /* ClassExpression */ + || kind === 232 /* VariableStatement */ + || kind === 251 /* FunctionDeclaration */ + || kind === 252 /* ClassDeclaration */ + || kind === 253 /* InterfaceDeclaration */ + || kind === 254 /* TypeAliasDeclaration */ + || kind === 255 /* EnumDeclaration */ + || kind === 256 /* ModuleDeclaration */ + || kind === 260 /* ImportEqualsDeclaration */ + || kind === 261 /* ImportDeclaration */ + || kind === 266 /* ExportAssignment */ + || kind === 267 /* ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; /* @internal */ @@ -27062,19 +27883,19 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 155 /* LastToken */) { + if (!node || node.kind <= 156 /* LastToken */) { return; } switch (node.kind) { - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -27082,9 +27903,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 287 /* SpreadAssignment */: + case 290 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 159 /* Parameter */: + case 160 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -27092,7 +27913,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -27100,51 +27921,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 161 /* PropertySignature */: + case 162 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 195 /* BindingElement */: + case 198 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 170 /* IndexSignature */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 171 /* IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 205 /* FunctionExpression */: - case 248 /* FunctionDeclaration */: - case 206 /* ArrowFunction */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 208 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 209 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -27156,364 +27977,374 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 172 /* TypeReference */: + case 173 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 171 /* TypePredicate */: + case 172 /* TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 175 /* TypeQuery */: + case 176 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 176 /* TypeLiteral */: + case 177 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 177 /* ArrayType */: + case 178 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 178 /* TupleType */: + case 179 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 181 /* UnionType */: - case 182 /* IntersectionType */: + case 182 /* UnionType */: + case 183 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 183 /* ConditionalType */: + case 184 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 184 /* InferType */: + case 185 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 192 /* ImportType */: + case 195 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 185 /* ParenthesizedType */: - case 187 /* TypeOperator */: + case 186 /* ParenthesizedType */: + case 188 /* TypeOperator */: return visitNode(cbNode, node.type); - case 188 /* IndexedAccessType */: + case 189 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 189 /* MappedType */: + case 190 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || + visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 190 /* LiteralType */: + case 191 /* LiteralType */: return visitNode(cbNode, node.literal); - case 191 /* NamedTupleMember */: + case 192 /* NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 193 /* ObjectBindingPattern */: - case 194 /* ArrayBindingPattern */: + case 196 /* ObjectBindingPattern */: + case 197 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 200 /* CallExpression */: - case 201 /* NewExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 203 /* TypeAssertionExpression */: + case 206 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 207 /* DeleteExpression */: + case 210 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 208 /* TypeOfExpression */: + case 211 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 209 /* VoidExpression */: + case 212 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 210 /* AwaitExpression */: + case 213 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 221 /* AsExpression */: + case 224 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 222 /* NonNullExpression */: + case 225 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 223 /* MetaProperty */: + case 226 /* MetaProperty */: return visitNode(cbNode, node.name); - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 217 /* SpreadElement */: + case 220 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 227 /* Block */: - case 254 /* ModuleBlock */: + case 230 /* Block */: + case 257 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 294 /* SourceFile */: + case 297 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 247 /* VariableDeclarationList */: + case 250 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 231 /* IfStatement */: + case 234 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 232 /* DoStatement */: + case 235 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 233 /* WhileStatement */: + case 236 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 237 /* ContinueStatement */: - case 238 /* BreakStatement */: + case 240 /* ContinueStatement */: + case 241 /* BreakStatement */: return visitNode(cbNode, node.label); - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 240 /* WithStatement */: + case 243 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 255 /* CaseBlock */: + case 258 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 281 /* CaseClause */: + case 284 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 282 /* DefaultClause */: + case 285 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 243 /* ThrowStatement */: + case 246 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 244 /* TryStatement */: + case 247 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 160 /* Decorator */: + case 161 /* Decorator */: return visitNode(cbNode, node.expression); - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 288 /* EnumMember */: + case 291 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 259 /* ImportClause */: + case 262 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 256 /* NamespaceExportDeclaration */: + case 259 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 266 /* NamespaceExport */: + case 269 /* NamespaceExport */: return visitNode(cbNode, node.name); - case 261 /* NamedImports */: - case 265 /* NamedExports */: + case 264 /* NamedImports */: + case 268 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 262 /* ImportSpecifier */: - case 267 /* ExportSpecifier */: + case 265 /* ImportSpecifier */: + case 270 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 215 /* TemplateExpression */: + case 218 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 225 /* TemplateSpan */: + case 228 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 157 /* ComputedPropertyName */: + case 193 /* TemplateLiteralType */: + return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); + case 194 /* TemplateLiteralTypeSpan */: + return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); + case 158 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 283 /* HeritageClause */: + case 286 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 269 /* ExternalModuleReference */: + case 272 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 268 /* MissingDeclaration */: + case 271 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 332 /* CommaListExpression */: + case 337 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 270 /* JsxElement */: + case 273 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 274 /* JsxFragment */: + case 277 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 271 /* JsxSelfClosingElement */: - case 272 /* JsxOpeningElement */: + case 274 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 278 /* JsxAttributes */: + case 281 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 277 /* JsxAttribute */: + case 280 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 279 /* JsxSpreadAttribute */: + case 282 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 280 /* JsxExpression */: + case 283 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 273 /* JsxClosingElement */: + case 276 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 179 /* OptionalType */: - case 180 /* RestType */: - case 298 /* JSDocTypeExpression */: - case 302 /* JSDocNonNullableType */: - case 301 /* JSDocNullableType */: - case 303 /* JSDocOptionalType */: - case 305 /* JSDocVariadicType */: + case 180 /* OptionalType */: + case 181 /* RestType */: + case 301 /* JSDocTypeExpression */: + case 306 /* JSDocNonNullableType */: + case 305 /* JSDocNullableType */: + case 307 /* JSDocOptionalType */: + case 309 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 304 /* JSDocFunctionType */: + case 308 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 307 /* JSDocComment */: + case 311 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 322 /* JSDocParameterTag */: - case 328 /* JSDocPropertyTag */: + case 332 /* JSDocSeeTag */: + return visitNode(cbNode, node.tagName) || + visitNode(cbNode, node.name); + case 302 /* JSDocNameReference */: + return visitNode(cbNode, node.name); + case 326 /* JSDocParameterTag */: + case 333 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 313 /* JSDocAuthorTag */: + case 317 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 312 /* JSDocImplementsTag */: + case 316 /* JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 311 /* JSDocAugmentsTag */: + case 315 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 326 /* JSDocTemplateTag */: + case 330 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 327 /* JSDocTypedefTag */: + case 331 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 298 /* JSDocTypeExpression */ + node.typeExpression.kind === 301 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 320 /* JSDocCallbackTag */: + case 324 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 323 /* JSDocReturnTag */: - case 325 /* JSDocTypeTag */: - case 324 /* JSDocThisTag */: - case 321 /* JSDocEnumTag */: + case 327 /* JSDocReturnTag */: + case 329 /* JSDocTypeTag */: + case 328 /* JSDocThisTag */: + case 325 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 309 /* JSDocSignature */: + case 313 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 308 /* JSDocTypeLiteral */: + case 312 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 310 /* JSDocTag */: - case 315 /* JSDocClassTag */: - case 316 /* JSDocPublicTag */: - case 317 /* JSDocPrivateTag */: - case 318 /* JSDocProtectedTag */: - case 319 /* JSDocReadonlyTag */: + case 314 /* JSDocTag */: + case 319 /* JSDocClassTag */: + case 320 /* JSDocPublicTag */: + case 321 /* JSDocPrivateTag */: + case 322 /* JSDocProtectedTag */: + case 323 /* JSDocReadonlyTag */: return visitNode(cbNode, node.tagName); - case 331 /* PartiallyEmittedExpression */: + case 336 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -27588,6 +28419,8 @@ var ts; ts.forEachChildRecursively = forEachChildRecursively; function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } + var tracingData = ["parse" /* Parse */, "createSourceFile", { path: fileName }]; + ts.tracing.begin.apply(ts.tracing, tracingData); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); @@ -27600,6 +28433,7 @@ var ts; ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); + ts.tracing.end.apply(ts.tracing, tracingData); return result; } ts.createSourceFile = createSourceFile; @@ -28460,7 +29294,7 @@ var ts; ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 268 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 271 /* MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -28574,7 +29408,7 @@ var ts; if (token() === 87 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 148 /* TypeKeyword */) { + if (token() === 149 /* TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); @@ -28582,7 +29416,7 @@ var ts; return nextTokenCanFollowDefaultKeyword(); case 123 /* StaticKeyword */: case 134 /* GetKeyword */: - case 145 /* SetKeyword */: + case 146 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -28992,14 +29826,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 165 /* Constructor */: - case 170 /* IndexSignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 162 /* PropertyDeclaration */: - case 226 /* SemicolonClassElement */: + case 166 /* Constructor */: + case 171 /* IndexSignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 163 /* PropertyDeclaration */: + case 229 /* SemicolonClassElement */: return true; - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. @@ -29014,8 +29848,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 281 /* CaseClause */: - case 282 /* DefaultClause */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: return true; } } @@ -29024,58 +29858,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 248 /* FunctionDeclaration */: - case 229 /* VariableStatement */: - case 227 /* Block */: - case 231 /* IfStatement */: - case 230 /* ExpressionStatement */: - case 243 /* ThrowStatement */: - case 239 /* ReturnStatement */: - case 241 /* SwitchStatement */: - case 238 /* BreakStatement */: - case 237 /* ContinueStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 234 /* ForStatement */: - case 233 /* WhileStatement */: - case 240 /* WithStatement */: - case 228 /* EmptyStatement */: - case 244 /* TryStatement */: - case 242 /* LabeledStatement */: - case 232 /* DoStatement */: - case 245 /* DebuggerStatement */: - case 258 /* ImportDeclaration */: - case 257 /* ImportEqualsDeclaration */: - case 264 /* ExportDeclaration */: - case 263 /* ExportAssignment */: - case 253 /* ModuleDeclaration */: - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: - case 251 /* TypeAliasDeclaration */: + case 251 /* FunctionDeclaration */: + case 232 /* VariableStatement */: + case 230 /* Block */: + case 234 /* IfStatement */: + case 233 /* ExpressionStatement */: + case 246 /* ThrowStatement */: + case 242 /* ReturnStatement */: + case 244 /* SwitchStatement */: + case 241 /* BreakStatement */: + case 240 /* ContinueStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 237 /* ForStatement */: + case 236 /* WhileStatement */: + case 243 /* WithStatement */: + case 231 /* EmptyStatement */: + case 247 /* TryStatement */: + case 245 /* LabeledStatement */: + case 235 /* DoStatement */: + case 248 /* DebuggerStatement */: + case 261 /* ImportDeclaration */: + case 260 /* ImportEqualsDeclaration */: + case 267 /* ExportDeclaration */: + case 266 /* ExportAssignment */: + case 256 /* ModuleDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: + case 254 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 288 /* EnumMember */; + return node.kind === 291 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 169 /* ConstructSignature */: - case 163 /* MethodSignature */: - case 170 /* IndexSignature */: - case 161 /* PropertySignature */: - case 168 /* CallSignature */: + case 170 /* ConstructSignature */: + case 164 /* MethodSignature */: + case 171 /* IndexSignature */: + case 162 /* PropertySignature */: + case 169 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 246 /* VariableDeclaration */) { + if (node.kind !== 249 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -29096,7 +29930,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 159 /* Parameter */) { + if (node.kind !== 160 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -29105,7 +29939,7 @@ var ts; } // Returns true if we should abort parsing. function abortParsingListOrMoveToNextToken(kind) { - parseErrorAtCurrentToken(parsingContextErrors(kind)); + parsingContextErrors(kind); if (isInSomeParsingContext()) { return true; } @@ -29114,31 +29948,34 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* BlockStatements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 3 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 0 /* SourceElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 5 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 6 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 7 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; - case 8 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 9 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; - case 10 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; - case 11 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 15 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 17 /* JSDocParameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 16 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 19 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 20 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 21 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 22 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - case 23 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; - case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected; - case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected; - default: return undefined; // TODO: GH#18217 `default: Debug.assertNever(context);` + case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* VariableDeclarations */: + return ts.isKeyword(token()) + ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) + : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); + case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* Parameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` } } // Parses a comma-delimited list of elements @@ -29283,6 +30120,24 @@ var ts; var pos = getNodePos(); return finishNode(factory.createTemplateExpression(parseTemplateHead(isTaggedTemplate), parseTemplateSpans(isTaggedTemplate)), pos); } + function parseTemplateType() { + var pos = getNodePos(); + return finishNode(factory.createTemplateLiteralType(parseTemplateHead(/*isTaggedTemplate*/ false), parseTemplateTypeSpans()), pos); + } + function parseTemplateTypeSpans() { + var pos = getNodePos(); + var list = []; + var node; + do { + node = parseTemplateTypeSpan(); + list.push(node); + } while (node.literal.kind === 16 /* TemplateMiddle */); + return createNodeArray(list, pos); + } + function parseTemplateTypeSpan() { + var pos = getNodePos(); + return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); + } function parseLiteralOfTemplateSpan(isTaggedTemplate) { if (token() === 19 /* CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); @@ -29356,14 +30211,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 172 /* TypeReference */: + case 173 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 173 /* FunctionType */: - case 174 /* ConstructorType */: { + case 174 /* FunctionType */: + case 175 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 185 /* ParenthesizedType */: + case 186 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -29443,7 +30298,7 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(138 /* ModuleKeyword */)) { + if (parseOptional(139 /* ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { @@ -29643,14 +30498,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 169 /* ConstructSignature */) { + if (kind === 170 /* ConstructSignature */) { parseExpected(102 /* NewKeyword */); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 168 /* CallSignature */ + var node = kind === 169 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -29773,10 +30628,10 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(168 /* CallSignature */); + return parseSignatureMember(169 /* CallSignature */); } if (token() === 102 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(169 /* ConstructSignature */); + return parseSignatureMember(170 /* ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); @@ -29820,9 +30675,9 @@ var ts; function isStartOfMappedType() { nextToken(); if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 141 /* ReadonlyKeyword */; + return nextToken() === 142 /* ReadonlyKeyword */; } - if (token() === 141 /* ReadonlyKeyword */) { + if (token() === 142 /* ReadonlyKeyword */) { nextToken(); } return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 100 /* InKeyword */; @@ -29838,14 +30693,15 @@ var ts; var pos = getNodePos(); parseExpected(18 /* OpenBraceToken */); var readonlyToken; - if (token() === 141 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 142 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 141 /* ReadonlyKeyword */) { - parseExpected(141 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 142 /* ReadonlyKeyword */) { + parseExpected(142 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); + var nameType = parseOptional(126 /* AsKeyword */) ? parseType() : undefined; parseExpected(23 /* CloseBracketToken */); var questionToken; if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { @@ -29857,7 +30713,7 @@ var ts; var type = parseTypeAnnotation(); parseSemicolon(); parseExpected(19 /* CloseBraceToken */); - return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), pos); + return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), pos); } function parseTupleElementType() { var pos = getNodePos(); @@ -29959,15 +30815,15 @@ var ts; function parseNonArrayType() { switch (token()) { case 128 /* AnyKeyword */: - case 151 /* UnknownKeyword */: - case 146 /* StringKeyword */: - case 143 /* NumberKeyword */: - case 154 /* BigIntKeyword */: - case 147 /* SymbolKeyword */: + case 152 /* UnknownKeyword */: + case 147 /* StringKeyword */: + case 144 /* NumberKeyword */: + case 155 /* BigIntKeyword */: + case 148 /* SymbolKeyword */: case 131 /* BooleanKeyword */: - case 149 /* UndefinedKeyword */: - case 140 /* NeverKeyword */: - case 144 /* ObjectKeyword */: + case 150 /* UndefinedKeyword */: + case 141 /* NeverKeyword */: + case 145 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); case 65 /* AsteriskEqualsToken */: @@ -30000,7 +30856,7 @@ var ts; return parseTokenNode(); case 107 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 136 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { @@ -30019,6 +30875,8 @@ var ts; return parseImportType(); case 127 /* AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); + case 15 /* TemplateHead */: + return parseTemplateType(); default: return parseTypeReference(); } @@ -30026,20 +30884,20 @@ var ts; function isStartOfType(inStartOfParameter) { switch (token()) { case 128 /* AnyKeyword */: - case 151 /* UnknownKeyword */: - case 146 /* StringKeyword */: - case 143 /* NumberKeyword */: - case 154 /* BigIntKeyword */: + case 152 /* UnknownKeyword */: + case 147 /* StringKeyword */: + case 144 /* NumberKeyword */: + case 155 /* BigIntKeyword */: case 131 /* BooleanKeyword */: - case 141 /* ReadonlyKeyword */: - case 147 /* SymbolKeyword */: - case 150 /* UniqueKeyword */: + case 142 /* ReadonlyKeyword */: + case 148 /* SymbolKeyword */: + case 151 /* UniqueKeyword */: case 113 /* VoidKeyword */: - case 149 /* UndefinedKeyword */: + case 150 /* UndefinedKeyword */: case 103 /* NullKeyword */: case 107 /* ThisKeyword */: case 111 /* TypeOfKeyword */: - case 140 /* NeverKeyword */: + case 141 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: case 29 /* LessThanToken */: @@ -30051,7 +30909,7 @@ var ts; case 9 /* BigIntLiteral */: case 109 /* TrueKeyword */: case 94 /* FalseKeyword */: - case 144 /* ObjectKeyword */: + case 145 /* ObjectKeyword */: case 41 /* AsteriskToken */: case 57 /* QuestionToken */: case 53 /* ExclamationToken */: @@ -30059,6 +30917,8 @@ var ts; case 135 /* InferKeyword */: case 99 /* ImportKeyword */: case 127 /* AssertsKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: return true; case 97 /* FunctionKeyword */: return !inStartOfParameter; @@ -30130,9 +30990,9 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 137 /* KeyOfKeyword */: - case 150 /* UniqueKeyword */: - case 141 /* ReadonlyKeyword */: + case 138 /* KeyOfKeyword */: + case 151 /* UniqueKeyword */: + case 142 /* ReadonlyKeyword */: return parseTypeOperator(operator); case 135 /* InferKeyword */: return parseInferType(); @@ -30249,7 +31109,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 136 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -30258,7 +31118,7 @@ var ts; var pos = getNodePos(); var assertsModifier = parseExpectedToken(127 /* AssertsKeyword */); var parameterName = token() === 107 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(136 /* IsKeyword */) ? parseType() : undefined; + var type = parseOptional(137 /* IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { @@ -30790,7 +31650,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 100 /* InKeyword */ || t === 155 /* OfKeyword */; + return t === 100 /* InKeyword */ || t === 156 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -30930,7 +31790,7 @@ var ts; if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 203 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 206 /* TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -31181,7 +32041,7 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 272 /* JsxOpeningElement */) { + if (opening.kind === 275 /* JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = parseJsxClosingElement(inExpressionContext); if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { @@ -31189,11 +32049,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 275 /* JsxOpeningFragment */) { + else if (opening.kind === 278 /* JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 271 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 274 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -31688,10 +32548,10 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 166 /* GetAccessor */); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); } - if (parseContextualModifier(145 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* SetAccessor */); + if (parseContextualModifier(146 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); } var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -31902,7 +32762,7 @@ var ts; } } var node; - if (awaitToken ? parseExpected(155 /* OfKeyword */) : parseOptional(155 /* OfKeyword */)) { + if (awaitToken ? parseExpected(156 /* OfKeyword */) : parseOptional(156 /* OfKeyword */)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); @@ -31928,10 +32788,10 @@ var ts; } function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); - parseExpected(kind === 238 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); + parseExpected(kind === 241 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 238 /* BreakStatement */ + var node = kind === 241 /* BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return finishNode(node, pos); @@ -32110,10 +32970,10 @@ var ts; // // could be legal, it would add complexity for very little gain. case 117 /* InterfaceKeyword */: - case 148 /* TypeKeyword */: + case 149 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 138 /* ModuleKeyword */: - case 139 /* NamespaceKeyword */: + case 139 /* ModuleKeyword */: + case 140 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); case 125 /* AbstractKeyword */: case 129 /* AsyncKeyword */: @@ -32121,14 +32981,14 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 122 /* PublicKeyword */: - case 141 /* ReadonlyKeyword */: + case 142 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 153 /* GlobalKeyword */: + case 154 /* GlobalKeyword */: nextToken(); return token() === 18 /* OpenBraceToken */ || token() === 78 /* Identifier */ || token() === 92 /* ExportKeyword */; case 99 /* ImportKeyword */: @@ -32137,7 +32997,7 @@ var ts; token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); case 92 /* ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 148 /* TypeKeyword */) { + if (currentToken_1 === 149 /* TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } if (currentToken_1 === 62 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || @@ -32193,17 +33053,17 @@ var ts; case 129 /* AsyncKeyword */: case 133 /* DeclareKeyword */: case 117 /* InterfaceKeyword */: - case 138 /* ModuleKeyword */: - case 139 /* NamespaceKeyword */: - case 148 /* TypeKeyword */: - case 153 /* GlobalKeyword */: + case 139 /* ModuleKeyword */: + case 140 /* NamespaceKeyword */: + case 149 /* TypeKeyword */: + case 154 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 123 /* StaticKeyword */: - case 141 /* ReadonlyKeyword */: + case 142 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -32246,9 +33106,9 @@ var ts; case 96 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 85 /* ContinueKeyword */: - return parseBreakOrContinueStatement(237 /* ContinueStatement */); + return parseBreakOrContinueStatement(240 /* ContinueStatement */); case 80 /* BreakKeyword */: - return parseBreakOrContinueStatement(238 /* BreakStatement */); + return parseBreakOrContinueStatement(241 /* BreakStatement */); case 104 /* ReturnKeyword */: return parseReturnStatement(); case 115 /* WithKeyword */: @@ -32269,9 +33129,9 @@ var ts; return parseDeclaration(); case 129 /* AsyncKeyword */: case 117 /* InterfaceKeyword */: - case 148 /* TypeKeyword */: - case 138 /* ModuleKeyword */: - case 139 /* NamespaceKeyword */: + case 149 /* TypeKeyword */: + case 139 /* ModuleKeyword */: + case 140 /* NamespaceKeyword */: case 133 /* DeclareKeyword */: case 84 /* ConstKeyword */: case 91 /* EnumKeyword */: @@ -32282,8 +33142,8 @@ var ts; case 122 /* PublicKeyword */: case 125 /* AbstractKeyword */: case 123 /* StaticKeyword */: - case 141 /* ReadonlyKeyword */: - case 153 /* GlobalKeyword */: + case 142 /* ReadonlyKeyword */: + case 154 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -32343,13 +33203,13 @@ var ts; return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); case 117 /* InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 148 /* TypeKeyword */: + case 149 /* TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); case 91 /* EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 153 /* GlobalKeyword */: - case 138 /* ModuleKeyword */: - case 139 /* NamespaceKeyword */: + case 154 /* GlobalKeyword */: + case 139 /* ModuleKeyword */: + case 140 /* NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); case 99 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -32368,7 +33228,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(268 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(271 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -32487,7 +33347,7 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 155 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 156 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -32591,12 +33451,12 @@ var ts; var parameters = parseParameters(0 /* None */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 166 /* GetAccessor */ + var node = kind === 167 /* GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 167 /* SetAccessor */) + if (type && node.kind === 168 /* SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -32635,7 +33495,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 145 /* SetKeyword */ || idToken === 134 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 146 /* SetKeyword */ || idToken === 134 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -32739,10 +33599,10 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 166 /* GetAccessor */); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); } - if (parseContextualModifier(145 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* SetAccessor */); + if (parseContextualModifier(146 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); } if (token() === 132 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -32781,10 +33641,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 218 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 221 /* ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 249 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); @@ -32806,7 +33666,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 249 /* ClassDeclaration */ + var node = kind === 252 /* ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -32866,11 +33726,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(148 /* TypeKeyword */); + parseExpected(149 /* TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); parseExpected(62 /* EqualsToken */); - var type = parseType(); + var type = token() === 136 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -32926,7 +33786,7 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 153 /* GlobalKeyword */) { + if (token() === 154 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); flags |= 1024 /* GlobalAugmentation */; @@ -32947,15 +33807,15 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 153 /* GlobalKeyword */) { + if (token() === 154 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(139 /* NamespaceKeyword */)) { + else if (parseOptional(140 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(138 /* ModuleKeyword */); + parseExpected(139 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } @@ -32963,7 +33823,7 @@ var ts; return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 142 /* RequireKeyword */ && + return token() === 143 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -32974,7 +33834,7 @@ var ts; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { parseExpected(126 /* AsKeyword */); - parseExpected(139 /* NamespaceKeyword */); + parseExpected(140 /* NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -32992,7 +33852,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 152 /* FromKeyword */ && + if (token() !== 153 /* FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -33010,7 +33870,7 @@ var ts; token() === 18 /* OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(152 /* FromKeyword */); + parseExpected(153 /* FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -33023,7 +33883,7 @@ var ts; function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 152 /* FromKeyword */; + return token() === 27 /* CommaToken */ || token() === 153 /* FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { parseExpected(62 /* EqualsToken */); @@ -33048,7 +33908,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(261 /* NamedImports */); + namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(264 /* NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -33059,7 +33919,7 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(142 /* RequireKeyword */); + parseExpected(143 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); var expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -33096,16 +33956,16 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 261 /* NamedImports */ + var node = kind === 264 /* NamedImports */ ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(267 /* ExportSpecifier */); + return parseImportOrExportSpecifier(270 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(262 /* ImportSpecifier */); + return parseImportOrExportSpecifier(265 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -33132,38 +33992,38 @@ var ts; else { name = identifierName; } - if (kind === 262 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 265 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 262 /* ImportSpecifier */ + var node = kind === 265 /* ImportSpecifier */ ? factory.createImportSpecifier(propertyName, name) : factory.createExportSpecifier(propertyName, name); return finishNode(node, pos); } function parseNamespaceExport(pos) { - return finishNode(factory.createNamespaceExport(parseIdentifier()), pos); + return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos); } function parseExportDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var exportClause; var moduleSpecifier; - var isTypeOnly = parseOptional(148 /* TypeKeyword */); + var isTypeOnly = parseOptional(149 /* TypeKeyword */); var namespaceExportPos = getNodePos(); if (parseOptional(41 /* AsteriskToken */)) { if (parseOptional(126 /* AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(152 /* FromKeyword */); + parseExpected(153 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(265 /* NamedExports */); + exportClause = parseNamedImportsOrExports(268 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 152 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(152 /* FromKeyword */); + if (token() === 153 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(153 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } @@ -33280,6 +34140,18 @@ var ts; return finishNode(result, pos); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; + function parseJSDocNameReference() { + var pos = getNodePos(); + var hasBrace = parseOptional(18 /* OpenBraceToken */); + var entityName = parseEntityName(/* allowReservedWords*/ false); + if (hasBrace) { + parseExpectedJSDoc(19 /* CloseBraceToken */); + } + var result = factory.createJSDocNameReference(entityName); + fixupParentReferences(result); + return finishNode(result, pos); + } + JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); @@ -33343,7 +34215,8 @@ var ts; var state = 1 /* SawAsterisk */; var margin; // + 4 for leading '/** ' - var indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4; + // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character + var indent = start - (content.lastIndexOf("\n", start) + 1) + 4; function pushComment(text) { if (!margin) { margin = indent; @@ -33399,7 +34272,7 @@ var ts; comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { - comments.push(whitespace.slice(margin - indent - 1)); + comments.push(whitespace.slice(margin - indent)); } indent += whitespace.length; break; @@ -33543,6 +34416,9 @@ var ts; case "callback": tag = parseCallbackTag(start, tagName, margin, indentText); break; + case "see": + tag = parseSeeTag(start, tagName, margin, indentText); + break; default: tag = parseUnknownTag(start, tagName, margin, indentText); break; @@ -33692,9 +34568,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 144 /* ObjectKeyword */: + case 145 /* ObjectKeyword */: return true; - case 177 /* ArrayType */: + case 178 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -33726,12 +34602,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 322 /* JSDocParameterTag */ || child.kind === 328 /* JSDocPropertyTag */) { + if (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 177 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178 /* ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -33753,6 +34629,12 @@ var ts; var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end); } + function parseSeeTag(start, tagName, indent, indentText) { + var nameExpression = parseJSDocNameReference(); + var end = getNodePos(); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; + return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end); + } function parseAuthorTag(start, tagName, indent, indentText) { var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -33868,7 +34750,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 325 /* JSDocTypeTag */) { + if (child.kind === 329 /* JSDocTypeTag */) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -33886,7 +34768,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 177 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 178 /* ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -33939,7 +34821,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 323 /* JSDocReturnTag */) { + if (tag && tag.kind === 327 /* JSDocReturnTag */) { return tag; } } @@ -33974,7 +34856,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 322 /* JSDocParameterTag */ || child.kind === 328 /* JSDocPropertyTag */) && + if (child && (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -34720,6 +35602,8 @@ var ts; } case "jsx": case "jsxfrag": + case "jsximportsource": + case "jsxruntime": return; // Accessed directly default: ts.Debug.fail("Unhandled pragma kind"); // Can this be made into an assertNever in the future? } @@ -34844,6 +35728,18 @@ var ts; (function (ts) { /* @internal */ ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + var jsxOptionMap = new ts.Map(ts.getEntries({ + "preserve": 1 /* Preserve */, + "react-native": 3 /* ReactNative */, + "react": 2 /* React */, + "react-jsx": 4 /* ReactJSX */, + "react-jsxdev": 5 /* ReactJSXDev */, + })); + /* @internal */ + ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { + var key = _a[0], value = _a[1]; + return ["" + value, key]; + }))); // NOTE: The order here is important to default lib ordering as entries will have the same // order in the generated program (see `getDefaultLibPriority` in program.ts). This // order also affects overload resolution when a type declared in one lib is @@ -34865,6 +35761,7 @@ var ts; ["dom.iterable", "lib.dom.iterable.d.ts"], ["webworker", "lib.webworker.d.ts"], ["webworker.importscripts", "lib.webworker.importscripts.d.ts"], + ["webworker.iterable", "lib.webworker.iterable.d.ts"], ["scripthost", "lib.scripthost.d.ts"], // ES2015 Or ESNext By-feature options ["es2015.core", "lib.es2015.core.d.ts"], @@ -34893,6 +35790,7 @@ var ts; ["es2019.symbol", "lib.es2019.symbol.d.ts"], ["es2020.bigint", "lib.es2020.bigint.d.ts"], ["es2020.promise", "lib.es2020.promise.d.ts"], + ["es2020.sharedmemory", "lib.es2020.sharedmemory.d.ts"], ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["es2020.intl", "lib.es2020.intl.d.ts"], @@ -34902,7 +35800,8 @@ var ts; ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], ["esnext.string", "lib.esnext.string.d.ts"], - ["esnext.promise", "lib.esnext.promise.d.ts"] + ["esnext.promise", "lib.esnext.promise.d.ts"], + ["esnext.weakref", "lib.esnext.weakref.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -35035,6 +35934,15 @@ var ts; description: ts.Diagnostics.Generates_a_CPU_profile }, { + name: "generateTrace", + type: "string", + isFilePath: true, + isCommandLineOnly: true, + paramType: ts.Diagnostics.DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types + }, + { name: "incremental", shortName: "i", type: "boolean", @@ -35189,12 +36097,10 @@ var ts; }, { name: "jsx", - type: new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */ - })), + type: jsxOptionMap, affectsSourceFile: true, + affectsEmit: true, + affectsModuleResolution: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, @@ -35437,6 +36343,14 @@ var ts; category: ts.Diagnostics.Additional_Checks, description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, + { + name: "noUncheckedIndexedAccess", + type: "boolean", + affectsSemanticDiagnostics: true, + showInSimplifiedHelpView: false, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Include_undefined_in_index_signature_results + }, // Module Resolution { name: "moduleResolution", @@ -35599,6 +36513,15 @@ var ts; description: ts.Diagnostics.Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment }, { + name: "jsxImportSource", + type: "string", + affectsSemanticDiagnostics: true, + affectsEmit: true, + affectsModuleResolution: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react + }, + { name: "resolveJsonModule", type: "boolean", affectsModuleResolution: true, @@ -35909,7 +36832,11 @@ var ts; name: "exclude", type: "string" } - } + }, + { + name: "disableFilenameBasedTypeAcquisition", + type: "boolean", + }, ]; /*@internal*/ function createOptionNameMap(optionDeclarations) { @@ -36264,7 +37191,7 @@ var ts; */ function readJsonConfigFile(fileName, readFile) { var textOrDiagnostic = tryReadFile(fileName, readFile); - return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { parseDiagnostics: [textOrDiagnostic] }; + return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { fileName: fileName, parseDiagnostics: [textOrDiagnostic] }; } ts.readJsonConfigFile = readJsonConfigFile; /*@internal*/ @@ -36407,7 +37334,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 285 /* PropertyAssignment */) { + if (element.kind !== 288 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -36498,13 +37425,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -36521,7 +37448,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -37006,6 +37933,7 @@ var ts; * It does *not* resolve the included files. */ function parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache) { + var _a; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -37015,6 +37943,13 @@ var ts; var ownConfig = json ? parseOwnConfigOfJson(json, host, basePath, configFileName, errors) : parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors); + if ((_a = ownConfig.options) === null || _a === void 0 ? void 0 : _a.paths) { + // If we end up needing to resolve relative paths from 'paths' relative to + // the config file location, we'll need to know where that config file was. + // Since 'paths' can be inherited from an extended config in another directory, + // we wouldn't know which directory to use unless we store it here. + ownConfig.options.pathsBasePath = basePath; + } if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); @@ -38314,12 +39249,15 @@ var ts; } function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; - if (baseUrl && paths && !ts.pathIsRelative(moduleName)) { + if (paths && !ts.pathIsRelative(moduleName)) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); + if (baseUrl) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); + } trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } - return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); + var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host); // Always defined when 'paths' is defined + return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, /*onlyRecordFailures*/ false, state); } } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { @@ -38818,6 +39756,7 @@ var ts; } var resolved = ts.forEach(paths[matchedPatternText], function (subst) { var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; + // When baseUrl is not specified, the command line parser resolves relative paths to the config file location. var candidate = ts.normalizePath(ts.combinePaths(baseDirectory, path)); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); @@ -38983,26 +39922,26 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 258 /* ImportDeclaration */: - case 257 /* ImportEqualsDeclaration */: + case 261 /* ImportDeclaration */: + case 260 /* ImportEqualsDeclaration */: if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 265 /* NamedExports */) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268 /* NamedExports */) { var state = 0 /* NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -39018,7 +39957,7 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 254 /* ModuleBlock */: { + case 257 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -39040,7 +39979,7 @@ var ts; }); return state_1; } - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return getModuleInstanceState(node, visited); case 78 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -39112,12 +40051,15 @@ var ts; } var binder = createBinder(); function bindSourceFile(file, options) { + var tracingData = ["bind" /* Bind */, "bindSourceFile", { path: file.path }]; + ts.tracing.begin.apply(ts.tracing, tracingData); ts.performance.mark("beforeBind"); ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); + ts.tracing.end.apply(ts.tracing, tracingData); } ts.bindSourceFile = bindSourceFile; function createBinder() { @@ -39149,6 +40091,8 @@ var ts; // not depending on if we see "use strict" in certain places or if we hit a class/namespace // or if compiler options contain alwaysStrict. var inStrictMode; + // If we are binding an assignment pattern, we will bind certain expressions differently. + var inAssignmentPattern = false; var symbolCount = 0; var Symbol; var classifiableNames; @@ -39198,6 +40142,7 @@ var ts; currentExceptionTarget = undefined; activeLabelList = undefined; hasExplicitReturn = false; + inAssignmentPattern = false; emitFlags = 0 /* None */; } return bindSourceFile; @@ -39235,7 +40180,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 263 /* ExportAssignment */) { + if (node.kind === 266 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -39244,7 +40189,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 157 /* ComputedPropertyName */) { + if (name.kind === 158 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -39272,36 +40217,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 165 /* Constructor */: + case 166 /* Constructor */: return "__constructor" /* Constructor */; - case 173 /* FunctionType */: - case 168 /* CallSignature */: - case 309 /* JSDocSignature */: + case 174 /* FunctionType */: + case 169 /* CallSignature */: + case 313 /* JSDocSignature */: return "__call" /* Call */; - case 174 /* ConstructorType */: - case 169 /* ConstructSignature */: + case 175 /* ConstructorType */: + case 170 /* ConstructSignature */: return "__new" /* New */; - case 170 /* IndexSignature */: + case 171 /* IndexSignature */: return "__index" /* Index */; - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 294 /* SourceFile */: + case 297 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 304 /* JSDocFunctionType */: + case 308 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 159 /* Parameter */: + case 160 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 304 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 308 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -39401,7 +40346,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 263 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 266 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -39438,9 +40383,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 267 /* ExportSpecifier */ || (node.kind === 257 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 270 /* ExportSpecifier */ || (node.kind === 260 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -39464,7 +40409,7 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } @@ -39479,6 +40424,28 @@ var ts; } } } + function jsdocTreatAsExported(node) { + if (node.parent && ts.isModuleDeclaration(node)) { + node = node.parent; + } + if (!ts.isJSDocTypeAlias(node)) + return false; + // jsdoc typedef handling is a bit of a doozy, but to summarize, treat the typedef as exported if: + // 1. It has an explicit name (since by default typedefs are always directly exported, either at the top level or in a container), or + if (!ts.isJSDocEnumTag(node) && !!node.fullName) + return true; + // 2. The thing a nameless typedef pulls its name from is implicitly a direct export (either by assignment or actual export flag). + var declName = ts.getNameOfDeclaration(node); + if (!declName) + return false; + if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) + return true; + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + return true; + // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should + // already have calculated and branched on most of this. + return false; + } // All container nodes are kept on a linked list in declaration order. This list is used by // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. @@ -39507,7 +40474,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 206 /* ArrowFunction */) { + if (node.kind !== 209 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -39540,7 +40507,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 165 /* Constructor */ || (ts.isInJSFile && (node.kind === 248 /* FunctionDeclaration */ || node.kind === 205 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 166 /* Constructor */ || (ts.isInJSFile && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -39555,13 +40522,13 @@ var ts; node.flags |= 512 /* HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 294 /* SourceFile */) { + if (node.kind === 297 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 165 /* Constructor */ || (ts.isInJSFile && (node.kind === 248 /* FunctionDeclaration */ || node.kind === 205 /* FunctionExpression */))) { + if (node.kind === 166 /* Constructor */ || (ts.isInJSFile && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -39588,8 +40555,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 248 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 248 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -39602,129 +40569,156 @@ var ts; ts.forEachChild(node, bind, bindEach); } function bindChildren(node) { + var saveInAssignmentPattern = inAssignmentPattern; + // Most nodes aren't valid in an assignment pattern, so we clear the value here + // and set it before we descend into nodes that could actually be part of an assignment pattern. + inAssignmentPattern = false; if (checkUnreachable(node)) { bindEachChild(node); bindJSDoc(node); + inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 229 /* FirstStatement */ && node.kind <= 245 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 232 /* FirstStatement */ && node.kind <= 248 /* LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 233 /* WhileStatement */: + case 236 /* WhileStatement */: bindWhileStatement(node); break; - case 232 /* DoStatement */: + case 235 /* DoStatement */: bindDoStatement(node); break; - case 234 /* ForStatement */: + case 237 /* ForStatement */: bindForStatement(node); break; - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 231 /* IfStatement */: + case 234 /* IfStatement */: bindIfStatement(node); break; - case 239 /* ReturnStatement */: - case 243 /* ThrowStatement */: + case 242 /* ReturnStatement */: + case 246 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 238 /* BreakStatement */: - case 237 /* ContinueStatement */: + case 241 /* BreakStatement */: + case 240 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 244 /* TryStatement */: + case 247 /* TryStatement */: bindTryStatement(node); break; - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: bindSwitchStatement(node); break; - case 255 /* CaseBlock */: + case 258 /* CaseBlock */: bindCaseBlock(node); break; - case 281 /* CaseClause */: + case 284 /* CaseClause */: bindCaseClause(node); break; - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: bindExpressionStatement(node); break; - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: bindLabeledStatement(node); break; - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: + if (ts.isDestructuringAssignment(node)) { + // Carry over whether we are in an assignment pattern to + // binary expressions that could actually be an initializer + inAssignmentPattern = saveInAssignmentPattern; + bindDestructuringAssignmentFlow(node); + return; + } bindBinaryExpressionFlow(node); break; - case 207 /* DeleteExpression */: + case 210 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 200 /* CallExpression */: + case 203 /* CallExpression */: bindCallExpressionFlow(node); break; - case 222 /* NonNullExpression */: + case 225 /* NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 327 /* JSDocTypedefTag */: - case 320 /* JSDocCallbackTag */: - case 321 /* JSDocEnumTag */: + case 331 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: + case 325 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 294 /* SourceFile */: { + case 297 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 227 /* Block */: - case 254 /* ModuleBlock */: + case 230 /* Block */: + case 257 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; + case 198 /* BindingElement */: + bindBindingElementFlow(node); + break; + case 200 /* ObjectLiteralExpression */: + case 199 /* ArrayLiteralExpression */: + case 288 /* PropertyAssignment */: + case 220 /* SpreadElement */: + // Carry over whether we are in an assignment pattern of Object and Array literals + // as well as their children that are valid assignment targets. + inAssignmentPattern = saveInAssignmentPattern; + // falls through default: bindEachChild(node); break; } bindJSDoc(node); + inAssignmentPattern = saveInAssignmentPattern; } function isNarrowingExpression(expr) { switch (expr.kind) { case 78 /* Identifier */: + case 79 /* PrivateIdentifier */: case 107 /* ThisKeyword */: - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: return containsNarrowableReference(expr); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return hasNarrowableArgument(expr); - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: + case 225 /* NonNullExpression */: return isNarrowingExpression(expr.expression); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 208 /* TypeOfExpression */: + case 211 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 78 /* Identifier */ || expr.kind === 107 /* ThisKeyword */ || expr.kind === 105 /* SuperKeyword */ || + return expr.kind === 78 /* Identifier */ || expr.kind === 79 /* PrivateIdentifier */ || expr.kind === 107 /* ThisKeyword */ || expr.kind === 105 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || + ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -39740,7 +40734,7 @@ var ts; } } } - if (expr.expression.kind === 198 /* PropertyAccessExpression */ && + if (expr.expression.kind === 201 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -39776,9 +40770,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -39854,26 +40848,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 231 /* IfStatement */: - case 233 /* WhileStatement */: - case 232 /* DoStatement */: + case 234 /* IfStatement */: + case 236 /* WhileStatement */: + case 235 /* DoStatement */: return parent.expression === node; - case 234 /* ForStatement */: - case 214 /* ConditionalExpression */: + case 237 /* ForStatement */: + case 217 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 204 /* ParenthesizedExpression */) { + if (node.kind === 207 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 211 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 214 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 213 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + return node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */); } @@ -39920,7 +40914,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 242 /* LabeledStatement */) { + while (label && node.parent.kind === 245 /* LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -39971,12 +40965,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 236 /* ForOfStatement */) { + if (node.kind === 239 /* ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 247 /* VariableDeclarationList */) { + if (node.initializer.kind !== 250 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -39998,7 +40992,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 239 /* ReturnStatement */) { + if (node.kind === 242 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -40015,7 +41009,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 238 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 241 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -40120,7 +41114,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 282 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -40163,10 +41157,13 @@ var ts; } function bindExpressionStatement(node) { bind(node.expression); - // A top level call expression with a dotted function name and at least one argument + maybeBindExpressionFlowIfCall(node.expression); + } + function maybeBindExpressionFlowIfCall(node) { + // A top level or LHS of comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.expression.kind === 200 /* CallExpression */) { - var call = node.expression; + if (node.kind === 203 /* CallExpression */) { + var call = node; if (ts.isDottedName(call.expression) && call.expression.kind !== 105 /* SuperKeyword */) { currentFlow = createFlowCall(currentFlow, call); } @@ -40191,7 +41188,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 213 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { + if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -40202,10 +41199,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); } - else if (node.kind === 196 /* ArrayLiteralExpression */) { + else if (node.kind === 199 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 217 /* SpreadElement */) { + if (e.kind === 220 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -40213,16 +41210,16 @@ var ts; } } } - else if (node.kind === 197 /* ObjectLiteralExpression */) { + else if (node.kind === 200 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 285 /* PropertyAssignment */) { + if (p.kind === 288 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 286 /* ShorthandPropertyAssignment */) { + else if (p.kind === 289 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 287 /* SpreadAssignment */) { + else if (p.kind === 290 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -40270,6 +41267,23 @@ var ts; bindAssignmentTargetFlow(node.operand); } } + function bindDestructuringAssignmentFlow(node) { + if (inAssignmentPattern) { + inAssignmentPattern = false; + bind(node.operatorToken); + bind(node.right); + inAssignmentPattern = true; + bind(node.left); + } + else { + inAssignmentPattern = true; + bind(node.left); + inAssignmentPattern = false; + bind(node.operatorToken); + bind(node.right); + } + bindAssignmentTargetFlow(node.left); + } var BindBinaryExpressionFlowState; (function (BindBinaryExpressionFlowState) { BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindThenBindChildren"] = 0] = "BindThenBindChildren"; @@ -40324,6 +41338,9 @@ var ts; break; } case 2 /* BindToken */: { + if (node.operatorToken.kind === 27 /* CommaToken */) { + maybeBindExpressionFlowIfCall(node.left); + } advanceState(3 /* BindRight */); maybeBind(node.operatorToken); break; @@ -40337,7 +41354,7 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 62 /* EqualsToken */ && node.left.kind === 199 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 202 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -40374,7 +41391,7 @@ var ts; * If `node` is a BinaryExpression, adds it to the local work stack, otherwise recursively binds it */ function maybeBind(node) { - if (node && ts.isBinaryExpression(node)) { + if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) { stackIndex++; workStacks.expr[stackIndex] = node; workStacks.state[stackIndex] = 0 /* BindThenBindChildren */; @@ -40388,7 +41405,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 198 /* PropertyAccessExpression */) { + if (node.expression.kind === 201 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -40425,9 +41442,27 @@ var ts; bindInitializedVariableFlow(node); } } + function bindBindingElementFlow(node) { + if (ts.isBindingPattern(node.name)) { + // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per: + // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization + // - `BindingElement: BindingPattern Initializer?` + // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization + // - `BindingElement: BindingPattern Initializer?` + bindEach(node.decorators); + bindEach(node.modifiers); + bind(node.dotDotDotToken); + bind(node.propertyName); + bind(node.initializer); + bind(node.name); + } + else { + bindEachChild(node); + } + } function bindJSDocTypeAlias(node) { ts.setParent(node.tagName, node); - if (node.kind !== 321 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 325 /* JSDocEnumTag */ && node.fullName) { ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); } @@ -40435,7 +41470,7 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 164 /* MethodDeclaration */) { + if (host && host.kind !== 165 /* MethodDeclaration */) { addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } } @@ -40448,15 +41483,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 200 /* CallExpression */: + case 203 /* CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -40521,7 +41556,7 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 205 /* FunctionExpression */ || expr.kind === 206 /* ArrowFunction */) { + if (expr.kind === 208 /* FunctionExpression */ || expr.kind === 209 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -40533,7 +41568,7 @@ var ts; } } } - if (node.expression.kind === 198 /* PropertyAccessExpression */) { + if (node.expression.kind === 201 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -40542,54 +41577,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 218 /* ClassExpression */: - case 249 /* ClassDeclaration */: - case 252 /* EnumDeclaration */: - case 197 /* ObjectLiteralExpression */: - case 176 /* TypeLiteral */: - case 308 /* JSDocTypeLiteral */: - case 278 /* JsxAttributes */: + case 221 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 255 /* EnumDeclaration */: + case 200 /* ObjectLiteralExpression */: + case 177 /* TypeLiteral */: + case 312 /* JSDocTypeLiteral */: + case 281 /* JsxAttributes */: return 1 /* IsContainer */; - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 253 /* ModuleDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 189 /* MappedType */: + case 256 /* ModuleDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 190 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 294 /* SourceFile */: + case 297 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 165 /* Constructor */: - case 248 /* FunctionDeclaration */: - case 163 /* MethodSignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 168 /* CallSignature */: - case 309 /* JSDocSignature */: - case 304 /* JSDocFunctionType */: - case 173 /* FunctionType */: - case 169 /* ConstructSignature */: - case 170 /* IndexSignature */: - case 174 /* ConstructorType */: + case 166 /* Constructor */: + case 251 /* FunctionDeclaration */: + case 164 /* MethodSignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 169 /* CallSignature */: + case 313 /* JSDocSignature */: + case 308 /* JSDocFunctionType */: + case 174 /* FunctionType */: + case 170 /* ConstructSignature */: + case 171 /* IndexSignature */: + case 175 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 254 /* ModuleBlock */: + case 257 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 284 /* CatchClause */: - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 255 /* CaseBlock */: + case 287 /* CatchClause */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 258 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 227 /* Block */: + case 230 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -40622,45 +41657,45 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 294 /* SourceFile */: + case 297 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 218 /* ClassExpression */: - case 249 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 252 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 176 /* TypeLiteral */: - case 308 /* JSDocTypeLiteral */: - case 197 /* ObjectLiteralExpression */: - case 250 /* InterfaceDeclaration */: - case 278 /* JsxAttributes */: + case 177 /* TypeLiteral */: + case 312 /* JSDocTypeLiteral */: + case 200 /* ObjectLiteralExpression */: + case 253 /* InterfaceDeclaration */: + case 281 /* JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 309 /* JSDocSignature */: - case 170 /* IndexSignature */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 304 /* JSDocFunctionType */: - case 327 /* JSDocTypedefTag */: - case 320 /* JSDocCallbackTag */: - case 251 /* TypeAliasDeclaration */: - case 189 /* MappedType */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 313 /* JSDocSignature */: + case 171 /* IndexSignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 308 /* JSDocFunctionType */: + case 331 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: + case 254 /* TypeAliasDeclaration */: + case 190 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -40761,7 +41796,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 287 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { + if (prop.kind === 290 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { continue; } var identifier = prop.name; @@ -40773,7 +41808,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 285 /* PropertyAssignment */ || prop.kind === 286 /* ShorthandPropertyAssignment */ || prop.kind === 164 /* MethodDeclaration */ + var currentKind = prop.kind === 288 /* PropertyAssignment */ || prop.kind === 289 /* ShorthandPropertyAssignment */ || prop.kind === 165 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -40805,10 +41840,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 294 /* SourceFile */: + case 297 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -41007,8 +42042,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 294 /* SourceFile */ && - blockScopeContainer.kind !== 253 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 297 /* SourceFile */ && + blockScopeContainer.kind !== 256 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -41103,7 +42138,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 155 /* LastToken */) { + if (node.kind > 156 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -41179,7 +42214,7 @@ var ts; } // falls through case 107 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 286 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 289 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); @@ -41188,8 +42223,8 @@ var ts; break; case 79 /* PrivateIdentifier */: return checkPrivateIdentifier(node); - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -41200,11 +42235,11 @@ var ts; if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && - !lookupSymbolForNameWorker(blockScopeContainer, "module")) { + !lookupSymbolForName(blockScopeContainer, "module")) { declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -41223,6 +42258,14 @@ var ts; bindThisPropertyAssignment(node); break; case 5 /* Property */: + var expression = node.left.expression; + if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { + var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); + if (ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration)) { + bindThisPropertyAssignment(node); + break; + } + } bindSpecialPropertyAssignment(node); break; case 0 /* None */: @@ -41232,78 +42275,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return checkStrictModeCatchClause(node); - case 207 /* DeleteExpression */: + case 210 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 240 /* WithStatement */: + case 243 /* WithStatement */: return checkStrictModeWithStatement(node); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 186 /* ThisType */: + case 187 /* ThisType */: seenThisKeyword = true; return; - case 171 /* TypePredicate */: + case 172 /* TypePredicate */: break; // Binding the children will handle everything - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: return bindTypeParameter(node); - case 159 /* Parameter */: + case 160 /* Parameter */: return bindParameter(node); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 195 /* BindingElement */: + case 198 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: return bindPropertyWorker(node); - case 285 /* PropertyAssignment */: - case 286 /* ShorthandPropertyAssignment */: + case 288 /* PropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 288 /* EnumMember */: + case 291 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 170 /* IndexSignature */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 171 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 165 /* Constructor */: + case 166 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 166 /* GetAccessor */: + case 167 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 167 /* SetAccessor */: + case 168 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 173 /* FunctionType */: - case 304 /* JSDocFunctionType */: - case 309 /* JSDocSignature */: - case 174 /* ConstructorType */: + case 174 /* FunctionType */: + case 308 /* JSDocFunctionType */: + case 313 /* JSDocSignature */: + case 175 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 176 /* TypeLiteral */: - case 308 /* JSDocTypeLiteral */: - case 189 /* MappedType */: + case 177 /* TypeLiteral */: + case 312 /* JSDocTypeLiteral */: + case 190 /* MappedType */: return bindAnonymousTypeWorker(node); - case 315 /* JSDocClassTag */: + case 319 /* JSDocClassTag */: return bindJSDocClassTag(node); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return bindFunctionExpression(node); - case 200 /* CallExpression */: + case 203 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -41322,65 +42365,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 218 /* ClassExpression */: - case 249 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 252 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 278 /* JsxAttributes */: + case 281 /* JsxAttributes */: return bindJsxAttributes(node); - case 277 /* JsxAttribute */: + case 280 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 257 /* ImportEqualsDeclaration */: - case 260 /* NamespaceImport */: - case 262 /* ImportSpecifier */: - case 267 /* ExportSpecifier */: + case 260 /* ImportEqualsDeclaration */: + case 263 /* NamespaceImport */: + case 265 /* ImportSpecifier */: + case 270 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 256 /* NamespaceExportDeclaration */: + case 259 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 259 /* ImportClause */: + case 262 /* ImportClause */: return bindImportClause(node); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return bindExportDeclaration(node); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return bindExportAssignment(node); - case 294 /* SourceFile */: + case 297 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 227 /* Block */: + case 230 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 254 /* ModuleBlock */: + case 257 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 322 /* JSDocParameterTag */: - if (node.parent.kind === 309 /* JSDocSignature */) { + case 326 /* JSDocParameterTag */: + if (node.parent.kind === 313 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 308 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 312 /* JSDocTypeLiteral */) { break; } // falls through - case 328 /* JSDocPropertyTag */: + case 333 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 303 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 327 /* JSDocTypedefTag */: - case 320 /* JSDocCallbackTag */: - case 321 /* JSDocEnumTag */: + case 331 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: + case 325 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -41501,9 +42544,9 @@ var ts; return symbol; }); if (symbol) { - var flags = ts.isClassExpression(node.right) ? - 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : - 4 /* Property */ | 1048576 /* ExportValue */; + var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); + var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + ts.setParent(node.left, node); declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } @@ -41519,6 +42562,10 @@ var ts; if (ts.isEmptyObjectLiteral(assignedExpression) || container === file && isExportsOrModuleExportsOrAlias(file, assignedExpression)) { return; } + if (ts.isObjectLiteralExpression(assignedExpression) && ts.every(assignedExpression.properties, ts.isShorthandPropertyAssignment)) { + ts.forEach(assignedExpression.properties, bindExportAssignedObjectMemberAlias); + return; + } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ @@ -41526,6 +42573,9 @@ var ts; var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); ts.setValueDeclaration(symbol, node); } + function bindExportAssignedObjectMemberAlias(node) { + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); // private identifiers *must* be declared (even in JS files) @@ -41536,8 +42586,8 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { @@ -41559,11 +42609,11 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 165 /* Constructor */: - case 162 /* PropertyDeclaration */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 166 /* Constructor */: + case 163 /* PropertyDeclaration */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -41575,7 +42625,7 @@ var ts; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); } break; - case 294 /* SourceFile */: + case 297 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; @@ -41604,7 +42654,7 @@ var ts; if (node.expression.kind === 107 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 294 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -41644,16 +42694,21 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 294 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 297 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { + var _a; // Class declarations in Typescript do not allow property declarations var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } + var rootExpr = ts.getLeftmostAccessExpression(node.left); + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + return; + } // Fix up parent pointers since we're going to use these nodes before we bind into them ts.setParent(node.left, node); ts.setParent(node.right, node); @@ -41687,17 +42742,17 @@ var ts; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; + var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { - addDeclarationToSymbol(symbol, id, flags_1); + addDeclarationToSymbol(symbol, id, flags_2); return symbol; } else { var table = parent ? parent.exports : file.jsGlobalAugmentations || (file.jsGlobalAugmentations = ts.createSymbolTable()); - return declareSymbol(table, parent, id, flags_1, excludeFlags_1); + return declareSymbol(table, parent, id, flags_2, excludeFlags_1); } }); } @@ -41748,8 +42803,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 294 /* SourceFile */ - : propertyAccess.parent.parent.kind === 294 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297 /* SourceFile */ + : propertyAccess.parent.parent.kind === 297 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -41796,7 +42851,7 @@ var ts; function lookupSymbolForPropertyAccess(node, lookupContainer) { if (lookupContainer === void 0) { lookupContainer = container; } if (ts.isIdentifier(node)) { - return lookupSymbolForNameWorker(lookupContainer, node.escapedText); + return lookupSymbolForName(lookupContainer, node.escapedText); } else { var symbol = lookupSymbolForPropertyAccess(node.expression); @@ -41828,7 +42883,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 249 /* ClassDeclaration */) { + if (node.kind === 252 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -41870,7 +42925,10 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isBlockOrCatchScoped(node)) { + if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !ts.getJSDocTypeTag(node)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + } + else if (ts.isBlockOrCatchScoped(node)) { bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { @@ -41891,7 +42949,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 322 /* JSDocParameterTag */ && container.kind !== 309 /* JSDocSignature */) { + if (node.kind === 326 /* JSDocParameterTag */ && container.kind !== 313 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -41968,7 +43026,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 184 /* InferType */) { + else if (node.parent.kind === 185 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -41996,11 +43054,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 228 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 231 /* EmptyStatement */) || // report error on class declarations - node.kind === 249 /* ClassDeclaration */ || + node.kind === 252 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 253 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 256 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -42044,12 +43102,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: return true; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: return ts.hasSyntacticModifier(s, 2048 /* Const */); default: return false; @@ -42065,7 +43123,7 @@ var ts; return true; } else if (ts.isIdentifier(node)) { - var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText); + var symbol = lookupSymbolForName(sourceFile, node.escapedText); if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) { var init = symbol.valueDeclaration.initializer; q.push(init); @@ -42079,7 +43137,7 @@ var ts; return false; } ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias; - function lookupSymbolForNameWorker(container, name) { + function lookupSymbolForName(container, name) { var local = container.locals && container.locals.get(name); if (local) { return local.exportSymbol || local; @@ -42249,7 +43307,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 175 /* TypeQuery */) { + if (d.type && d.type.kind === 176 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -42279,6 +43337,7 @@ var ts; IterationUse[IterationUse["YieldStarFlag"] = 16] = "YieldStarFlag"; IterationUse[IterationUse["SpreadFlag"] = 32] = "SpreadFlag"; IterationUse[IterationUse["DestructuringFlag"] = 64] = "DestructuringFlag"; + IterationUse[IterationUse["PossiblyOutOfBounds"] = 128] = "PossiblyOutOfBounds"; // Spread, Destructuring, Array element assignment IterationUse[IterationUse["Element"] = 1] = "Element"; IterationUse[IterationUse["Spread"] = 33] = "Spread"; @@ -42425,6 +43484,7 @@ var ts; AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + AccessFlags[AccessFlags["ExpressionPosition"] = 16] = "ExpressionPosition"; })(AccessFlags || (AccessFlags = {})); var SignatureCheckMode; (function (SignatureCheckMode) { @@ -42483,6 +43543,25 @@ var ts; DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; })(DeclarationSpaces || (DeclarationSpaces = {})); + var MinArgumentCountFlags; + (function (MinArgumentCountFlags) { + MinArgumentCountFlags[MinArgumentCountFlags["None"] = 0] = "None"; + MinArgumentCountFlags[MinArgumentCountFlags["StrongArityForUntypedJS"] = 1] = "StrongArityForUntypedJS"; + MinArgumentCountFlags[MinArgumentCountFlags["VoidIsNonOptional"] = 2] = "VoidIsNonOptional"; + })(MinArgumentCountFlags || (MinArgumentCountFlags = {})); + var IntrinsicTypeKind; + (function (IntrinsicTypeKind) { + IntrinsicTypeKind[IntrinsicTypeKind["Uppercase"] = 0] = "Uppercase"; + IntrinsicTypeKind[IntrinsicTypeKind["Lowercase"] = 1] = "Lowercase"; + IntrinsicTypeKind[IntrinsicTypeKind["Capitalize"] = 2] = "Capitalize"; + IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; + })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); + var intrinsicTypeKinds = new ts.Map(ts.getEntries({ + Uppercase: 0 /* Uppercase */, + Lowercase: 1 /* Lowercase */, + Capitalize: 2 /* Capitalize */, + Uncapitalize: 3 /* Uncapitalize */ + })); function SymbolLinks() { } function NodeLinks() { @@ -42546,6 +43625,7 @@ var ts; var instantiationDepth = 0; var constraintDepth = 0; var currentNode; + var typeCatalog = []; // NB: id is index + 1 var emptySymbols = ts.createSymbolTable(); var arrayVariances = [1 /* Covariant */]; var compilerOptions = host.getCompilerOptions(); @@ -42582,6 +43662,7 @@ var ts; getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, + getTypeCatalog: function () { return typeCatalog; }, getTypeCount: function () { return typeCount; }, getInstantiationCount: function () { return totalInstantiationCount; }, getRelationCacheSizes: function () { return ({ @@ -42596,6 +43677,7 @@ var ts; getMergedSymbol: getMergedSymbol, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, + getRecursionIdentity: getRecursionIdentity, getTypeOfSymbolAtLocation: function (symbol, locationIn) { var location = ts.getParseTreeNode(locationIn); return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType; @@ -42704,6 +43786,7 @@ var ts; }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, + getSymbolOfExpando: getSymbolOfExpando, getContextualType: function (nodeIn, contextFlags) { var node = ts.getParseTreeNode(nodeIn, ts.isExpression); if (!node) { @@ -42897,6 +43980,8 @@ var ts; var intersectionTypes = new ts.Map(); var literalTypes = new ts.Map(); var indexedAccessTypes = new ts.Map(); + var templateLiteralTypes = new ts.Map(); + var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); @@ -42907,6 +43992,7 @@ var ts; var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 524288 /* ContainsWideningType */); + var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 524288 /* ContainsWideningType */); @@ -42945,6 +44031,7 @@ var ts; var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); + var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -43216,6 +44303,16 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { + // Pseudo-synthesized input node + if (location.pos < 0 || location.end < 0) { + if (!isError) { + return; // Drop suggestions (we have no span to suggest on) + } + // Issue errors globally + var file = ts.getSourceFileOfNode(location); + addErrorOrSuggestion(isError, "message" in message ? ts.createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForFileFromMessageChain(file, message)); // eslint-disable-line no-in-operator + return; + } addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { @@ -43505,7 +44602,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 294 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -43564,17 +44661,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 195 /* BindingElement */) { + if (declaration.kind === 198 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 195 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 198 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 246 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 249 /* VariableDeclaration */), usage); } - else if (declaration.kind === 246 /* VariableDeclaration */) { + else if (declaration.kind === 249 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -43604,12 +44701,12 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 267 /* ExportSpecifier */ || (usage.parent.kind === 263 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 270 /* ExportSpecifier */ || (usage.parent.kind === 266 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 263 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 266 /* ExportAssignment */ && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { @@ -43631,9 +44728,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 229 /* VariableStatement */: - case 234 /* ForStatement */: - case 236 /* ForOfStatement */: + case 232 /* VariableStatement */: + case 237 /* ForStatement */: + case 239 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -43654,16 +44751,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 162 /* PropertyDeclaration */ && + current.parent.kind === 163 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasSyntacticModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 164 /* MethodDeclaration */) { + if (declaration.kind === 165 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 162 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -43685,19 +44782,19 @@ var ts; return "quit"; } switch (node.kind) { - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return true; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 227 /* Block */: + case 230 /* Block */: switch (node.parent.kind) { - case 166 /* GetAccessor */: - case 164 /* MethodDeclaration */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 165 /* MethodDeclaration */: + case 168 /* SetAccessor */: return true; default: return false; @@ -43733,18 +44830,18 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 206 /* ArrowFunction */: - case 205 /* FunctionExpression */: - case 248 /* FunctionDeclaration */: - case 165 /* Constructor */: + case 209 /* ArrowFunction */: + case 208 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 166 /* Constructor */: // do not descend into these return false; - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 285 /* PropertyAssignment */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 288 /* PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { return target < 99 /* ESNext */ || !compilerOptions.useDefineForClassFields; @@ -43798,12 +44895,12 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 307 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 311 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 159 /* Parameter */ || - lastLocation.kind === 158 /* TypeParameter */ + lastLocation.kind === 160 /* Parameter */ || + lastLocation.kind === 159 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -43818,13 +44915,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 159 /* Parameter */ || + lastLocation.kind === 160 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 183 /* ConditionalType */) { + else if (location.kind === 184 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -43839,14 +44936,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 294 /* SourceFile */: + case 297 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 294 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 297 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -43870,7 +44967,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 267 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 266 /* NamespaceExport */))) { + (ts.getDeclarationOfKind(moduleExport, 270 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 269 /* NamespaceExport */))) { break; } } @@ -43884,12 +44981,12 @@ var ts; } } break; - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -43906,9 +45003,9 @@ var ts; } } break; - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! @@ -43927,7 +45024,7 @@ var ts; } break loop; } - if (location.kind === 218 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 221 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -43935,7 +45032,7 @@ var ts; } } break; - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 93 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -43955,9 +45052,9 @@ var ts; // [foo<T>()]() { } // <-- Reference to T from class's own computed property // } // - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 250 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 253 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -43965,24 +45062,24 @@ var ts; } } break; - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 164 /* MethodDeclaration */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 248 /* FunctionDeclaration */: + case 165 /* MethodDeclaration */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 251 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -43995,7 +45092,7 @@ var ts; } } break; - case 160 /* Decorator */: + case 161 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -44004,7 +45101,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 159 /* Parameter */) { + if (location.parent && location.parent.kind === 160 /* Parameter */) { location = location.parent; } // @@ -44019,17 +45116,17 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C<T> {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 249 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 252 /* ClassDeclaration */)) { location = location.parent; } break; - case 327 /* JSDocTypedefTag */: - case 320 /* JSDocCallbackTag */: - case 321 /* JSDocEnumTag */: + case 331 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: + case 325 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 159 /* Parameter */: + case 160 /* Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -44037,14 +45134,20 @@ var ts; } } break; - case 195 /* BindingElement */: + case 198 /* BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { - var root = ts.getRootDeclaration(location); - if (root.kind === 159 /* Parameter */) { - if (!associatedDeclarationForContainingInitializerOrBindingName) { - associatedDeclarationForContainingInitializerOrBindingName = location; - } + if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location; + } + } + break; + case 185 /* InferType */: + if (meaning & 262144 /* TypeParameter */) { + var parameterName = location.typeParameter.name; + if (parameterName && name === parameterName.escapedText) { + result = location.typeParameter.symbol; + break loop; } } break; @@ -44063,7 +45166,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 294 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 297 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -44101,7 +45204,15 @@ var ts; } } if (!suggestion) { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); + if (nameArg) { + var lib = getSuggestedLibForNonExistentName(nameArg); + if (lib) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib); + } + else { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); + } + } } suggestionCount++; } @@ -44180,10 +45291,10 @@ var ts; } } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 206 /* ArrowFunction */ && location.kind !== 205 /* FunctionExpression */) { + if (location.kind !== 209 /* ArrowFunction */ && location.kind !== 208 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 162 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -44196,12 +45307,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 248 /* FunctionDeclaration */: - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 253 /* ModuleDeclaration */: // For `namespace N { N; }` + case 251 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 256 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -44213,7 +45324,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 158 /* TypeParameter */) { + if (decl.kind === 159 /* TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -44269,9 +45380,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 78 /* Identifier */: - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -44315,7 +45426,7 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 267 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 270 /* ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -44329,15 +45440,31 @@ var ts; } var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { - var message = isES2015OrLaterConstructorName(name) - ? ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later - : ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here; - error(errorLocation, message, ts.unescapeLeadingUnderscores(name)); + var rawName = ts.unescapeLeadingUnderscores(name); + if (isES2015OrLaterConstructorName(name)) { + error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); + } + else if (maybeMappedType(errorLocation, symbol)) { + error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0, rawName, rawName === "K" ? "P" : "K"); + } + else { + error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, rawName); + } return true; } } return false; } + function maybeMappedType(node, symbol) { + var container = ts.findAncestor(node.parent, function (n) { + return ts.isComputedPropertyName(n) || ts.isPropertySignature(n) ? false : ts.isTypeLiteralNode(n) || "quit"; + }); + if (container && container.members.length === 1) { + var type = getDeclaredTypeOfSymbol(symbol); + return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + } + return false; + } function isES2015OrLaterConstructorName(n) { switch (n) { case "Promise": @@ -44374,7 +45501,7 @@ var ts; return; } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 252 /* EnumDeclaration */); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255 /* EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -44409,13 +45536,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return node; - case 259 /* ImportClause */: + case 262 /* ImportClause */: return node.parent; - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: return node.parent.parent; - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -44439,29 +45566,37 @@ var ts; * {name: <EntityNameExpression>} */ function isAliasSymbolDeclaration(node) { - return node.kind === 257 /* ImportEqualsDeclaration */ || - node.kind === 256 /* NamespaceExportDeclaration */ || - node.kind === 259 /* ImportClause */ && !!node.name || - node.kind === 260 /* NamespaceImport */ || - node.kind === 266 /* NamespaceExport */ || - node.kind === 262 /* ImportSpecifier */ || - node.kind === 267 /* ExportSpecifier */ || - node.kind === 263 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) + return node.kind === 260 /* ImportEqualsDeclaration */ + || node.kind === 259 /* NamespaceExportDeclaration */ + || node.kind === 262 /* ImportClause */ && !!node.name + || node.kind === 263 /* NamespaceImport */ + || node.kind === 269 /* NamespaceExport */ + || node.kind === 265 /* ImportSpecifier */ + || node.kind === 270 /* ExportSpecifier */ + || node.kind === 266 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ - && isAliasableOrJsExpression(node.parent.right) || - node.kind === 286 /* ShorthandPropertyAssignment */ || - node.kind === 285 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer); + && isAliasableOrJsExpression(node.parent.right) + || node.kind === 289 /* ShorthandPropertyAssignment */ + || node.kind === 288 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 269 /* ExternalModuleReference */) { - var immediate = resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node)); + var commonJSPropertyAccess = getCommonJSPropertyAccess(node); + if (commonJSPropertyAccess) { + var name = ts.getLeftmostAccessExpression(commonJSPropertyAccess.expression).arguments[0]; + return ts.isIdentifier(commonJSPropertyAccess.name) + ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) + : undefined; + } + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272 /* ExternalModuleReference */) { + var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); return resolved_4; @@ -44488,10 +45623,7 @@ var ts; } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); - if (exportValue) { - return getPropertyOfType(getTypeOfSymbol(exportValue), name); - } - var exportSymbol = moduleSymbol.exports.get(name); + var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; @@ -44632,11 +45764,9 @@ var ts; result.exports = new ts.Map(valueSymbol.exports); return result; } - function getExportOfModule(symbol, specifier, dontResolveAlias) { - var _a; + function getExportOfModule(symbol, name, specifier, dontResolveAlias) { if (symbol.flags & 1536 /* Module */) { - var name = ((_a = specifier.propertyName) !== null && _a !== void 0 ? _a : specifier.name).escapedText; - var exportSymbol = getExportsOfSymbol(symbol).get(name); + var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; @@ -44653,10 +45783,14 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { var _a; if (dontResolveAlias === void 0) { dontResolveAlias = false; } - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var name = specifier.propertyName || specifier.name; + var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier; + var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier); // TODO: GH#18217 + var name = !ts.isPropertyAccessExpression(specifier) && specifier.propertyName || specifier.name; + if (!ts.isIdentifier(name)) { + return undefined; + } var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { @@ -44672,7 +45806,7 @@ var ts; } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); - var symbolFromModule = getExportOfModule(targetSymbol, specifier, dontResolveAlias); + var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) { @@ -44688,7 +45822,7 @@ var ts; var suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol); if (suggestion !== undefined) { var suggestionName = symbolToString(suggestion); - var diagnostic = error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2, moduleName, declarationName, suggestionName); + var diagnostic = error(name, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName); if (suggestion.valueDeclaration) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName)); } @@ -44749,10 +45883,21 @@ var ts; } } function getTargetOfImportSpecifier(node, dontResolveAlias) { - var resolved = getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias); + var root = ts.isBindingElement(node) ? ts.getRootDeclaration(node) : node.parent.parent.parent; + var commonJSPropertyAccess = getCommonJSPropertyAccess(root); + var resolved = getExternalModuleMember(root, commonJSPropertyAccess || node, dontResolveAlias); + var name = node.propertyName || node.name; + if (commonJSPropertyAccess && resolved && ts.isIdentifier(name)) { + return getPropertyOfType(getTypeOfSymbol(resolved), name.escapedText); + } markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false); return resolved; } + function getCommonJSPropertyAccess(node) { + if (ts.isVariableDeclaration(node) && node.initializer && ts.isPropertyAccessExpression(node.initializer)) { + return node.initializer; + } + } function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) { var resolved = resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false); @@ -44789,7 +45934,7 @@ var ts; var expression = node.initializer; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } - function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + function getTargetOfAccessExpression(node, dontRecursivelyResolve) { if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { return undefined; } @@ -44798,29 +45943,32 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: + case 249 /* VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 259 /* ImportClause */: + case 262 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 266 /* NamespaceExport */: + case 269 /* NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: + case 198 /* BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 267 /* ExportSpecifier */: + case 270 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 263 /* ExportAssignment */: - case 213 /* BinaryExpression */: + case 266 /* ExportAssignment */: + case 216 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 256 /* NamespaceExportDeclaration */: + case 259 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 198 /* PropertyAccessExpression */: - return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); + case 202 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -44887,7 +46035,7 @@ var ts; * @param overwriteEmpty Checks `resolvesToSymbol` for type-only declarations even if `aliasDeclaration` */ function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) { - if (!aliasDeclaration) + if (!aliasDeclaration || ts.isPropertyAccessExpression(aliasDeclaration)) return false; // If the declaration itself is type-only, mark it and return. // No need to check what it resolves to. @@ -44971,13 +46119,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 156 /* QualifiedName */) { + if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 157 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 257 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 260 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -45001,9 +46149,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 156 /* QualifiedName */ || name.kind === 198 /* PropertyAccessExpression */) { - var left = name.kind === 156 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 156 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 157 /* QualifiedName */ || name.kind === 201 /* PropertyAccessExpression */) { + var left = name.kind === 157 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 157 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -45029,7 +46177,12 @@ var ts; symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning)); if (!symbol) { if (!ignoreErrors) { - error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + var namespaceName = getFullyQualifiedName(namespace); + var declarationName = ts.declarationNameToString(right); + var suggestion = getSuggestedSymbolForNonexistentModule(right, namespace); + suggestion ? + error(right, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestion)) : + error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName); } return undefined; } @@ -45038,7 +46191,7 @@ var ts; throw ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 263 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 266 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -45222,7 +46375,7 @@ var ts; ? ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1, packageId.name, ts.mangleScopedPackageName(packageId.name)) : ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference, ts.mangleScopedPackageName(packageId.name)) + /*details*/ undefined, ts.Diagnostics.Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference, ts.mangleScopedPackageName(packageId.name)) : undefined; errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } @@ -45264,7 +46417,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 294 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 297 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -45566,7 +46719,7 @@ var ts; var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 165 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 166 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -45575,6 +46728,7 @@ var ts; var result = new Type(checker, flags); typeCount++; result.id = typeCount; + typeCatalog.push(result); return result; } function createIntrinsicType(kind, intrinsicName, objectFlags) { @@ -45653,12 +46807,12 @@ var ts; } } switch (location.kind) { - case 294 /* SourceFile */: + case 297 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -45667,9 +46821,9 @@ var ts; return { value: result }; } break; - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -45752,7 +46906,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 267 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 270 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -45796,7 +46950,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 267 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 270 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -45811,10 +46965,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 162 /* PropertyDeclaration */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 163 /* PropertyDeclaration */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: continue; default: return false; @@ -45943,10 +47097,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 294 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 294 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -45955,6 +47109,7 @@ var ts; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { + var _a, _b; if (!isDeclarationVisible(declaration)) { // Mark the unexported alias as visible if its parent is visible // because these kind of aliases can be used to name types in declaration file @@ -45974,6 +47129,14 @@ var ts; && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } + else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + && ts.isVariableDeclaration(declaration.parent.parent) + && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) + && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) + && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + } // Declaration is not visible return false; } @@ -45993,14 +47156,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 175 /* TypeQuery */ || + if (entityName.parent.kind === 176 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 157 /* ComputedPropertyName */) { + entityName.parent.kind === 158 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 156 /* QualifiedName */ || entityName.kind === 198 /* PropertyAccessExpression */ || - entityName.parent.kind === 257 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 157 /* QualifiedName */ || entityName.kind === 201 /* PropertyAccessExpression */ || + entityName.parent.kind === 260 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -46041,7 +47204,7 @@ var ts; function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 294 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 297 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; @@ -46053,10 +47216,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 174 /* ConstructorType */ : 173 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructorType */ : 174 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 169 /* ConstructSignature */ : 168 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructSignature */ : 169 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -46102,6 +47265,9 @@ var ts; if (flags === void 0) { flags = 0 /* None */; } return flags & 814775659 /* NodeBuilderFlagsMask */; } + function isClassInstanceSide(type) { + return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824 /* IsClassInstanceClone */)); + } function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { @@ -46133,6 +47299,7 @@ var ts; }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { + var _a, _b; ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, @@ -46156,6 +47323,9 @@ var ts; approximateLength: 0 }; var resultingNode = cb(context); + if (context.truncating && context.flags & 1 /* NoTruncation */) { + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); + } return context.encounteredError ? undefined : resultingNode; } function checkTruncationLength(context) { @@ -46182,22 +47352,22 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 /* IntrinsicKeyword */ : 128 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(151 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(146 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(147 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(143 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(144 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(154 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(155 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; @@ -46206,10 +47376,23 @@ var ts; if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); - var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type - ? parentName - : appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); - return enumLiteralName; + if (getDeclaredTypeOfSymbol(parentSymbol) === type) { + return parentName; + } + var memberName = ts.symbolName(type.symbol); + if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); + } + if (ts.isImportTypeNode(parentName)) { + parentName.isTypeOf = true; // mutably update, node is freshly manufactured anyhow + return ts.factory.createIndexedAccessTypeNode(parentName, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(memberName))); + } + else if (ts.isTypeReferenceNode(parentName)) { + return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeQueryNode(parentName.typeName), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(memberName))); + } + else { + return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); + } } if (type.flags & 1056 /* EnumLike */) { return symbolToTypeNode(type.symbol, context, 788968 /* Type */); @@ -46242,7 +47425,7 @@ var ts; } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(150 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(147 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(151 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; @@ -46250,7 +47433,7 @@ var ts; } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(149 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; @@ -46258,15 +47441,15 @@ var ts; } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(140 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(141 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(144 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(145 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -46334,7 +47517,19 @@ var ts; var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(137 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, indexTypeNode); + } + if (type.flags & 134217728 /* TemplateLiteral */) { + var texts_1 = type.texts; + var types_1 = type.types; + var templateHead = ts.factory.createTemplateHead(texts_1[0]); + var templateSpans = ts.factory.createNodeArray(ts.map(types_1, function (t, i) { return ts.factory.createTemplateLiteralTypeSpan(typeToTypeNodeHelper(t, context), (i < types_1.length - 1 ? ts.factory.createTemplateMiddle : ts.factory.createTemplateTail)(texts_1[i + 1])); })); + context.approximateLength += 2; + return ts.factory.createTemplateLiteralType(templateHead, templateSpans); + } + if (type.flags & 268435456 /* StringMapping */) { + var typeNode = typeToTypeNodeHelper(type.type, context); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); } if (type.flags & 8388608 /* IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); @@ -46379,14 +47574,15 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(137 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); + var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; var templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context); - var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode); context.approximateLength += 10; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); } @@ -46395,16 +47591,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { + var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 218 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 111551 /* Value */); + return symbolToTypeNode(symbol, context, isInstanceType); } else if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name @@ -46432,7 +47628,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 294 /* SourceFile */ || declaration.parent.kind === 254 /* ModuleBlock */; + return declaration.parent.kind === 297 /* SourceFile */ || declaration.parent.kind === 257 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -46483,12 +47679,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 173 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 174 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 174 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 175 /* ConstructorType */, context); return signatureNode; } } @@ -46509,7 +47705,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(141 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -46533,12 +47729,12 @@ var ts; } } var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(141 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(141 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -46566,10 +47762,10 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); - var flags_2 = context.flags; + var flags_3 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); - context.flags = flags_2; + context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } } @@ -46645,11 +47841,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 168 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 169 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 169 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 170 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -46725,7 +47921,7 @@ var ts; var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 163 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 164 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -46740,7 +47936,7 @@ var ts; propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(141 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -46748,8 +47944,8 @@ var ts; typeElements.push(preserveCommentsOn(propertySignature)); } function preserveCommentsOn(node) { - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 328 /* JSDocPropertyTag */; })) { - var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 328 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; }); var commentText = d.comment; if (commentText) { ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); @@ -46781,8 +47977,8 @@ var ts; var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_4 = []; var i = 0; - for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { - var type = types_1[_i]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); @@ -46817,8 +48013,8 @@ var ts; var b = _b[0]; return typesAreSameReference(a, b); })) { - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var _a = types_2[_i], type = _a[0], resultIndex = _a[1]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var _a = types_3[_i], type = _a[0], resultIndex = _a[1]; result_4[resultIndex] = typeToTypeNodeHelper(type, context); } } @@ -46835,7 +48031,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 146 /* StringKeyword */ : 143 /* NumberKeyword */); + var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 147 /* StringKeyword */ : 144 /* NumberKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -46850,7 +48046,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(141 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; @@ -46865,7 +48061,9 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0].map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 165 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; + // If the expanded parameter list had a variadic in a non-trailing position, don't expand it + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 166 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -46892,20 +48090,20 @@ var ts; } } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum - var node = kind === 168 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 169 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 163 /* MethodSignature */ ? ts.factory.createMethodSignature(options === null || options === void 0 ? void 0 : options.modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 164 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 165 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, parameters, /*body*/ undefined) : - kind === 166 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 167 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 170 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, parameters, returnTypeNode) : - kind === 304 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 173 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 174 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 248 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 205 /* FunctionExpression */ ? ts.factory.createFunctionExpression(options === null || options === void 0 ? void 0 : options.modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 206 /* ArrowFunction */ ? ts.factory.createArrowFunction(options === null || options === void 0 ? void 0 : options.modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + var node = kind === 169 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 170 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 164 /* MethodSignature */ ? ts.factory.createMethodSignature(options === null || options === void 0 ? void 0 : options.modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 165 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 166 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, parameters, /*body*/ undefined) : + kind === 167 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 168 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 171 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, parameters, returnTypeNode) : + kind === 308 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 174 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 175 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 251 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, options === null || options === void 0 ? void 0 : options.modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 208 /* FunctionExpression */ ? ts.factory.createFunctionExpression(options === null || options === void 0 ? void 0 : options.modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 209 /* ArrowFunction */ ? ts.factory.createArrowFunction(options === null || options === void 0 ? void 0 : options.modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -46927,9 +48125,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 159 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 322 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -46944,7 +48142,7 @@ var ts; var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 78 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 156 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 157 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -47109,11 +48307,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 294 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 297 /* SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 294 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 297 /* SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -47152,7 +48350,7 @@ var ts; // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; - specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" })); + specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map()); links.specifierCache.set(contextFile.path, specifier); } @@ -47458,7 +48656,7 @@ var ts; } var oldFlags = context.flags; if (type.flags & 8192 /* UniqueESSymbol */ && - type.symbol === symbol) { + type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { context.flags |= 1048576 /* AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); @@ -47491,17 +48689,17 @@ var ts; function visitExistingNodeTreeSymbols(node) { var _a, _b; // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 306 /* JSDocNamepathType */) { + if (ts.isJSDocAllType(node) || node.kind === 310 /* JSDocNamepathType */) { return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(151 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(149 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -47615,8 +48813,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 164 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 163 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164 /* MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -47895,38 +49093,50 @@ var ts; if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; } - var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ - ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); - if (name !== localName && !isPrivate) { - // We rename the variable declaration we generate for Property symbols since they may have a name which - // conflicts with a local declaration. For example, given input: - // ``` - // function g() {} - // module.exports.g = g - // ``` - // In such a situation, we have a local variable named `g`, and a separate exported variable named `g`. - // Naively, we would emit - // ``` - // function g() {} - // export const g: typeof g; - // ``` - // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but - // the export declaration shadows it. - // To work around that, we instead write - // ``` - // function g() {} - // const g_1: typeof g; - // export { g_1 as g }; - // ``` - // To create an export named `g` that does _not_ shadow the local `g` + var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression); + if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right) + && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) { + var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(name, localName)])), 0 /* None */); - needsExportDeclaration = false; - needsPostExportDefault = false; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(alias, localName)])), 0 /* None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + } + else { + var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ + ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a separate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.factory.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(name, localName)])), 0 /* None */); + needsExportDeclaration = false; + needsPostExportDefault = false; + } } } } @@ -47948,7 +49158,8 @@ var ts; if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } - if (symbol.flags & 64 /* Interface */) { + // The class meaning serialization should handle serializing all interface members + if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } if (symbol.flags & 2097152 /* Alias */) { @@ -48043,8 +49254,8 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 168 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 169 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 169 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 170 /* ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( @@ -48113,7 +49324,7 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 248 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 251 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); // for expressions assigned to `var`s, use the `var` as the text range addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags); } @@ -48176,7 +49387,7 @@ var ts; } function isNamespaceMember(p) { return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isClassLike(p.valueDeclaration.parent)); + !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.getEffectiveModifierFlags(p.valueDeclaration) & 32 /* Static */ && ts.isClassLike(p.valueDeclaration.parent)); } function serializeAsClass(symbol, localName, modifierFlags) { var _a; @@ -48227,13 +49438,14 @@ var ts; !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 165 /* Constructor */); + serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 166 /* Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); addResult(ts.setTextRange(ts.factory.createClassDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, publicProperties, privateProperties)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); } function serializeAsAlias(symbol, localName, modifierFlags) { + var _a, _b, _c, _d, _e; // synthesize an alias, eg `export { symbolName as Name }` // need to mark the alias `symbol` points at // as something we need to serialize as a private declaration as well @@ -48252,23 +49464,66 @@ var ts; var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 257 /* ImportEqualsDeclaration */: + case 198 /* BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249 /* VariableDeclaration */) { + // const { SomeClass } = require('./lib'); + var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' + var propertyName = node.propertyName; + addResult(ts.factory.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1)), 0 /* None */); + break; + } + // We don't know how to serialize this (nested?) binding element + ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); + break; + case 289 /* ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216 /* BinaryExpression */) { + // module.exports = { SomeClass } + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); + } + break; + case 249 /* VariableDeclaration */: + // commonjs require: const x = require('y') + if (ts.isPropertyAccessExpression(node.initializer)) { + // const x = require('y').z + var initializer = node.initializer; // require('y').z + var uniqueName = ts.factory.createUniqueName(localName); // _x + var specifier_2 = getSpecifierForModuleSymbol(target.parent || target, context); // 'y' + // import _x = require('y'); + addResult(ts.factory.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + // import x = _x.z + addResult(ts.factory.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createQualifiedName(uniqueName, initializer.name)), modifierFlags); + break; + } + // else fall through and treat commonjs require just like import= + case 260 /* ImportEqualsDeclaration */: + // This _specifically_ only exists to handle json declarations - where we make aliases, but since + // we emit no declarations for the json document, must not refer to it in the declarations + if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + serializeMaybeAliasAssignment(symbol); + break; + } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */); + var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), isLocalImport ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); break; - case 256 /* NamespaceExportDeclaration */: + case 259 /* NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); break; - case 259 /* ImportClause */: + case 262 /* ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -48277,18 +49532,18 @@ var ts; // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 266 /* NamespaceExport */: + case 269 /* NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -48297,7 +49552,7 @@ var ts; ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 267 /* ExportSpecifier */: + case 270 /* ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -48305,11 +49560,12 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 213 /* BinaryExpression */: - case 198 /* PropertyAccessExpression */: + case 216 /* BinaryExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier @@ -48340,7 +49596,7 @@ var ts; var name = ts.unescapeLeadingUnderscores(symbol.escapedName); var isExportEquals = name === "export=" /* ExportEquals */; var isDefault = name === "default" /* Default */; - var isExportAssignment = isExportEquals || isDefault; + var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or // a reference to another namespace/module which we may need to emit an `import` statement for @@ -48352,8 +49608,8 @@ var ts; // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it // eg, `namespace A { export class B {} }; exports = A.B;` // Technically, this is all that's required in the case where the assignment is an entity name expression - var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); - var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); + var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); @@ -48365,17 +49621,17 @@ var ts; // into the containing scope anyway, so we want to skip the visibility checks. var oldTrack = context.tracker.trackSymbol; context.tracker.trackSymbol = ts.noop; - if (isExportAssignment) { + if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); } else { - if (first_1 === expr) { + if (first_1 === expr && first_1) { // serialize as `export {target as name}` serializeExportSpecifier(name, ts.idText(first_1)); } - else if (ts.isClassExpression(expr)) { + else if (expr && ts.isClassExpression(expr)) { serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); } else { @@ -48398,15 +49654,19 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], 2 /* Const */)); - addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. + // Otherwise, the type itself should be exported. + addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ + : name === varName ? 1 /* Export */ + : 0 /* None */); } - if (isExportAssignment) { + if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, /*modifiers*/ undefined, isExportEquals, ts.factory.createIdentifier(varName))); @@ -48427,7 +49687,8 @@ var ts; return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !getIndexInfoOfType(typeToSerialize, 0 /* String */) && !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && - !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && + !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && @@ -48475,7 +49736,7 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { return ts.setTextRange(createProperty( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 @@ -48718,7 +49979,7 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 251 /* TypeAliasDeclaration */) { + if (node.kind === 254 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -48726,11 +49987,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 254 /* ModuleBlock */ && + node.parent.kind === 257 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 294 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 297 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; @@ -48789,17 +50050,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 246 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 249 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 218 /* ClassExpression */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 221 /* ClassExpression */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 218 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 221 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -48816,28 +50077,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 320 /* JSDocCallbackTag */: - case 327 /* JSDocTypedefTag */: - case 321 /* JSDocEnumTag */: + case 324 /* JSDocCallbackTag */: + case 331 /* JSDocTypedefTag */: + case 325 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 195 /* BindingElement */: + case 198 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 253 /* ModuleDeclaration */: - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 248 /* FunctionDeclaration */: - case 252 /* EnumDeclaration */: - case 257 /* ImportEqualsDeclaration */: + case 256 /* ModuleDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 251 /* FunctionDeclaration */: + case 255 /* EnumDeclaration */: + case 260 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -48845,55 +50106,55 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 257 /* ImportEqualsDeclaration */ && parent.kind !== 294 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { + !(node.kind !== 260 /* ImportEqualsDeclaration */ && parent.kind !== 297 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 165 /* Constructor */: - case 169 /* ConstructSignature */: - case 168 /* CallSignature */: - case 170 /* IndexSignature */: - case 159 /* Parameter */: - case 254 /* ModuleBlock */: - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 176 /* TypeLiteral */: - case 172 /* TypeReference */: - case 177 /* ArrayType */: - case 178 /* TupleType */: - case 181 /* UnionType */: - case 182 /* IntersectionType */: - case 185 /* ParenthesizedType */: - case 191 /* NamedTupleMember */: + case 166 /* Constructor */: + case 170 /* ConstructSignature */: + case 169 /* CallSignature */: + case 171 /* IndexSignature */: + case 160 /* Parameter */: + case 257 /* ModuleBlock */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 177 /* TypeLiteral */: + case 173 /* TypeReference */: + case 178 /* ArrayType */: + case 179 /* TupleType */: + case 182 /* UnionType */: + case 183 /* IntersectionType */: + case 186 /* ParenthesizedType */: + case 192 /* NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 259 /* ImportClause */: - case 260 /* NamespaceImport */: - case 262 /* ImportSpecifier */: + case 262 /* ImportClause */: + case 263 /* NamespaceImport */: + case 265 /* ImportSpecifier */: return false; // Type parameters are always visible - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: // Source file and namespace export are always visible // falls through - case 294 /* SourceFile */: - case 256 /* NamespaceExportDeclaration */: + case 297 /* SourceFile */: + case 259 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return false; default: return false; @@ -48902,10 +50163,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 263 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 266 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 267 /* ExportSpecifier */) { + else if (node.parent.kind === 270 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -49010,12 +50271,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 246 /* VariableDeclaration */: - case 247 /* VariableDeclarationList */: - case 262 /* ImportSpecifier */: - case 261 /* NamedImports */: - case 260 /* NamespaceImport */: - case 259 /* ImportClause */: + case 249 /* VariableDeclaration */: + case 250 /* VariableDeclarationList */: + case 265 /* ImportSpecifier */: + case 264 /* NamedImports */: + case 263 /* NamespaceImport */: + case 262 /* ImportClause */: return false; default: return true; @@ -49100,9 +50361,13 @@ var ts; var propName = getDestructuringPropertyName(node); if (propName) { var literal = ts.setTextRange(ts.parseNodeFactory.createStringLiteral(propName), node); - var result = ts.setTextRange(ts.parseNodeFactory.createElementAccessExpression(parentAccess, literal), node); + var lhsExpr = ts.isLeftHandSideExpression(parentAccess) ? parentAccess : ts.parseNodeFactory.createParenthesizedExpression(parentAccess); + var result = ts.setTextRange(ts.parseNodeFactory.createElementAccessExpression(lhsExpr, literal), node); ts.setParent(literal, result); ts.setParent(result, node); + if (lhsExpr !== parentAccess) { + ts.setParent(lhsExpr, result); + } result.flowNode = parentAccess.flowNode; return result; } @@ -49111,23 +50376,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 195 /* BindingElement */: - case 285 /* PropertyAssignment */: + case 198 /* BindingElement */: + case 288 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return ancestor.initializer; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 195 /* BindingElement */ && parent.kind === 193 /* ObjectBindingPattern */) { + if (node.kind === 198 /* BindingElement */ && parent.kind === 196 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 285 /* PropertyAssignment */ || node.kind === 286 /* ShorthandPropertyAssignment */) { + if (node.kind === 288 /* PropertyAssignment */ || node.kind === 289 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -49153,7 +50418,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); } var type; - if (pattern.kind === 193 /* ObjectBindingPattern */) { + if (pattern.kind === 196 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { @@ -49173,7 +50438,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, name), declaration.name); + var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */), declaration.name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -49181,7 +50446,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -49194,7 +50459,7 @@ var ts; else if (isArrayLikeType(parentType)) { var indexType = getLiteralType(index_2); var accessFlags = hasDefaultValue(declaration) ? 8 /* NoTupleBoundsCheck */ : 0; - var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, declaration.name, accessFlags) || errorType, declaration.name); + var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, declaration.name, accessFlags | 16 /* ExpressionPosition */) || errorType, declaration.name); type = getFlowTypeOfDestructuring(declaration, declaredType); } else { @@ -49226,7 +50491,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 196 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 199 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -49236,11 +50501,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 235 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 238 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 236 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -49277,8 +50542,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 167 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 166 /* GetAccessor */); + if (func.kind === 168 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -49345,10 +50610,11 @@ var ts; if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isConstructorDeclaredProperty === undefined) { + links.isConstructorDeclaredProperty = false; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && - ts.getAssignmentDeclarationKind(declaration) === 4 /* ThisProperty */ && - (declaration.left.kind !== 199 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + isPossiblyAliasedThisProperty(declaration) && + (declaration.left.kind !== 202 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -49367,13 +50633,16 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); - if (container && (container.kind === 165 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 166 /* Constructor */ || isJSConstructor(container))) { return container; } } } function getFlowTypeInConstructor(symbol, constructor) { - var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), ts.unescapeLeadingUnderscores(symbol.escapedName)); + var accessName = ts.startsWith(symbol.escapedName, "__#") + ? ts.factory.createPrivateIdentifier(symbol.escapedName.split("@")[1]) + : ts.unescapeLeadingUnderscores(symbol.escapedName); + var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), accessName); ts.setParent(reference.expression, reference); ts.setParent(reference, constructor); reference.flowNode = constructor.returnFlowNode; @@ -49421,7 +50690,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -49538,6 +50807,7 @@ var ts; var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); + var initialSize = members_4.size; if (resolvedSymbol && !resolvedSymbol.exports) { resolvedSymbol.exports = ts.createSymbolTable(); } @@ -49576,8 +50846,12 @@ var ts; members_4.set(name, s); } }); - var result = createAnonymousType(exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); + var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type + members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); result.objectFlags |= (ts.getObjectFlags(type) & 16384 /* JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 1073741824 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + } return result; } if (isEmptyArrayLiteralType(type)) { @@ -49595,9 +50869,9 @@ var ts; var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 165 /* Constructor */ || - thisContainer.kind === 248 /* FunctionDeclaration */ || - (thisContainer.kind === 205 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 166 /* Constructor */ || + thisContainer.kind === 251 /* FunctionDeclaration */ || + (thisContainer.kind === 208 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -49667,7 +50941,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 195 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 198 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -49692,7 +50966,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 193 /* ObjectBindingPattern */ + return pattern.kind === 196 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -49731,7 +51005,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 159 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 160 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -49794,7 +51068,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 263 /* ExportAssignment */) { + if (declaration.kind === 266 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -49865,7 +51139,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 166 /* GetAccessor */) { + if (accessor.kind === 167 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -49899,15 +51173,15 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 166 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } return type; } function resolveTypeOfAccessors(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 166 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 167 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 168 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -49958,9 +51232,9 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.type) { - var jsDeclaration = symbol.valueDeclaration && ts.getDeclarationOfExpando(symbol.valueDeclaration); - if (jsDeclaration) { - var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + var expando = symbol.valueDeclaration && getSymbolOfExpando(symbol.valueDeclaration, /*allowDeclaration*/ false); + if (expando) { + var merged = mergeJSSymbols(symbol, expando); if (merged) { // note:we overwrite links because we just cloned the symbol symbol = links = merged; @@ -49975,9 +51249,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 213 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 216 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 213 /* BinaryExpression */)) { + declaration.parent.kind === 216 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -50044,7 +51318,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 159 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 160 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -50143,43 +51417,43 @@ var ts; return undefined; } switch (node.kind) { - case 229 /* VariableStatement */: - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 163 /* MethodSignature */: - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 304 /* JSDocFunctionType */: - case 248 /* FunctionDeclaration */: - case 164 /* MethodDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 251 /* TypeAliasDeclaration */: - case 326 /* JSDocTemplateTag */: - case 327 /* JSDocTypedefTag */: - case 321 /* JSDocEnumTag */: - case 320 /* JSDocCallbackTag */: - case 189 /* MappedType */: - case 183 /* ConditionalType */: + case 232 /* VariableStatement */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 164 /* MethodSignature */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 308 /* JSDocFunctionType */: + case 251 /* FunctionDeclaration */: + case 165 /* MethodDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 254 /* TypeAliasDeclaration */: + case 330 /* JSDocTemplateTag */: + case 331 /* JSDocTypedefTag */: + case 325 /* JSDocEnumTag */: + case 324 /* JSDocCallbackTag */: + case 190 /* MappedType */: + case 184 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 189 /* MappedType */) { + if (node.kind === 190 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 183 /* ConditionalType */) { + else if (node.kind === 184 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } - else if (node.kind === 229 /* VariableStatement */ && !ts.isInJSFile(node)) { + else if (node.kind === 232 /* VariableStatement */ && !ts.isInJSFile(node)) { break; } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 249 /* ClassDeclaration */ || node.kind === 218 /* ClassExpression */ || node.kind === 250 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */ || node.kind === 253 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; - case 322 /* JSDocParameterTag */: + case 326 /* JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; @@ -50190,7 +51464,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 250 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 253 /* InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -50200,9 +51474,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 250 /* InterfaceDeclaration */ || - node.kind === 249 /* ClassDeclaration */ || - node.kind === 218 /* ClassExpression */ || + if (node.kind === 253 /* InterfaceDeclaration */ || + node.kind === 252 /* ClassDeclaration */ || + node.kind === 221 /* ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -50346,7 +51620,7 @@ var ts; if (!popTypeResolution()) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 249 /* ClassDeclaration */ || declaration.kind === 250 /* InterfaceDeclaration */) { + if (declaration.kind === 252 /* ClassDeclaration */ || declaration.kind === 253 /* InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -50441,7 +51715,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 250 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 253 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -50477,7 +51751,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 250 /* InterfaceDeclaration */) { + if (declaration.kind === 253 /* InterfaceDeclaration */) { if (declaration.flags & 128 /* ContainsThis */) { return false; } @@ -50565,7 +51839,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 213 /* BinaryExpression */) { + else if (expr.kind === 216 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -50580,12 +51854,12 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 78 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -50599,7 +51873,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 252 /* EnumDeclaration */) { + if (declaration.kind === 255 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { @@ -50626,7 +51900,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 252 /* EnumDeclaration */) { + if (declaration.kind === 255 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -50699,21 +51973,21 @@ var ts; function isThislessType(node) { switch (node.kind) { case 128 /* AnyKeyword */: - case 151 /* UnknownKeyword */: - case 146 /* StringKeyword */: - case 143 /* NumberKeyword */: - case 154 /* BigIntKeyword */: + case 152 /* UnknownKeyword */: + case 147 /* StringKeyword */: + case 144 /* NumberKeyword */: + case 155 /* BigIntKeyword */: case 131 /* BooleanKeyword */: - case 147 /* SymbolKeyword */: - case 144 /* ObjectKeyword */: + case 148 /* SymbolKeyword */: + case 145 /* ObjectKeyword */: case 113 /* VoidKeyword */: - case 149 /* UndefinedKeyword */: - case 140 /* NeverKeyword */: - case 190 /* LiteralType */: + case 150 /* UndefinedKeyword */: + case 141 /* NeverKeyword */: + case 191 /* LiteralType */: return true; - case 177 /* ArrayType */: + case 178 /* ArrayType */: return isThislessType(node.elementType); - case 172 /* TypeReference */: + case 173 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -50739,7 +52013,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 165 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 166 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -50755,14 +52029,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -50967,7 +52241,7 @@ var ts; links[resolutionKind] = earlySymbols || emptySymbols; // fill in any as-yet-unresolved late-bound members. var lateSymbols = ts.createSymbolTable(); - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + for (var _i = 0, _a = symbol.declarations || ts.emptyArray; _i < _a.length; _i++) { var decl = _a[_i]; var members = ts.getMembersOfDeclaration(decl); if (members) { @@ -50986,7 +52260,7 @@ var ts; var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ - || assignmentKind === 4 /* ThisProperty */ + || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic === !isInstanceMember && hasLateBindableName(member)) { @@ -51109,6 +52383,7 @@ var ts; sig.resolvedReturnType = resolvedReturnType; sig.resolvedTypePredicate = resolvedTypePredicate; sig.minArgumentCount = minArgumentCount; + sig.resolvedMinArgumentCount = undefined; sig.target = undefined; sig.mapper = undefined; sig.unionSignatures = undefined; @@ -51352,8 +52627,8 @@ var ts; function getUnionIndexInfo(types, kind) { var indexTypes = []; var isAnyReadonly = false; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; var indexInfo = getIndexInfoOfType(getApparentType(type), kind); if (!indexInfo) { return undefined; @@ -51552,9 +52827,6 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & (1 /* Any */ | 131068 /* Primitive */)) { - return type; - } if (type.flags & 4194304 /* Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); @@ -51575,7 +52847,7 @@ var ts; if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } - return neverType; + return type; } /** Resolve the members of a mapped type { [P in K]: T } */ function resolveMappedTypeMembers(type) { @@ -51588,6 +52860,7 @@ var ts; // and T as the template type. var typeParameter = getTypeParameterFromMappedType(type); var constraintType = getConstraintTypeFromMappedType(type); + var nameType = getNameTypeFromMappedType(type.target || type); var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); @@ -51609,25 +52882,25 @@ var ts; forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - function addMemberForKeyType(t) { - // Create a mapper from T to the current iteration type constituent. Then, if the - // mapped type is itself an instantiated type, combine the iteration mapper with the - // instantiation mapper. - var templateMapper = appendTypeMapping(type.mapper, typeParameter, t); + function addMemberForKeyType(keyType) { + var propNameType = nameType ? instantiateType(nameType, appendTypeMapping(type.mapper, typeParameter, keyType)) : keyType; + forEachType(propNameType, function (t) { return addMemberForKeyTypeWorker(keyType, t); }); + } + function addMemberForKeyTypeWorker(keyType, propNameType) { // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (isTypeUsableAsPropertyName(t)) { - var propName = getPropertyNameFromType(t); + if (isTypeUsableAsPropertyName(propNameType)) { + var propName = getPropertyNameFromType(propNameType); // String enum members from separate enums with identical values // are distinct types with the same property name. Make the resulting // property symbol's name type be the union of those enum member types. var existingProp = members.get(propName); if (existingProp) { - existingProp.nameType = getUnionType([existingProp.nameType, t]); - existingProp.mapper = appendTypeMapping(type.mapper, typeParameter, existingProp.nameType); + existingProp.nameType = getUnionType([existingProp.nameType, propNameType]); + existingProp.keyType = getUnionType([existingProp.keyType, keyType]); } else { - var modifiersProp = getPropertyOfType(modifiersType, propName); + var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || @@ -51635,19 +52908,19 @@ var ts; var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); prop.mappedType = type; + prop.nameType = propNameType; + prop.keyType = keyType; if (modifiersProp) { prop.syntheticOrigin = modifiersProp; prop.declarations = modifiersProp.declarations; } - prop.nameType = t; - prop.mapper = templateMapper; members.set(propName, prop); } } - else if (t.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 32 /* Enum */)) { - var propType = instantiateType(templateType, templateMapper); - if (t.flags & (1 /* Any */ | 4 /* String */)) { - stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + else if (propNameType.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 32 /* Enum */)) { + var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); + if (propNameType.flags & (1 /* Any */ | 4 /* String */)) { + stringIndexInfo = createIndexInfo(stringIndexInfo ? getUnionType([stringIndexInfo.type, propType]) : propType, !!(templateModifiers & 1 /* IncludeReadonly */)); } else { numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1 /* IncludeReadonly */)); @@ -51657,12 +52930,14 @@ var ts; } function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { + var mappedType = symbol.mappedType; if (!pushTypeResolution(symbol, 0 /* Type */)) { - symbol.mappedType.containsError = true; + mappedType.containsError = true; return errorType; } - var templateType = getTemplateTypeFromMappedType(symbol.mappedType.target || symbol.mappedType); - var propType = instantiateType(templateType, symbol.mapper); + var templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType); + var mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.keyType); + var propType = instantiateType(templateType, mapper); // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. @@ -51670,11 +52945,10 @@ var ts; symbol.checkFlags & 524288 /* StripOptional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (!popTypeResolution()) { - error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(symbol.mappedType)); + error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); type = errorType; } symbol.type = type; - symbol.mapper = undefined; } return symbol.type; } @@ -51686,6 +52960,11 @@ var ts; return type.constraintType || (type.constraintType = getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)) || errorType); } + function getNameTypeFromMappedType(type) { + return type.declaration.nameType ? + type.nameType || (type.nameType = instantiateType(getTypeFromTypeNode(type.declaration.nameType), type.mapper)) : + undefined; + } function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? @@ -51697,8 +52976,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 187 /* TypeOperator */ && - constraintDeclaration.operator === 137 /* KeyOfKeyword */; + return constraintDeclaration.kind === 188 /* TypeOperator */ && + constraintDeclaration.operator === 138 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -51832,8 +53111,8 @@ var ts; return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var memberType = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var memberType = types_5[_i]; for (var _a = 0, _b = getAugmentedPropertiesOfType(memberType); _a < _b.length; _a++) { var escapedName = _b[_a].escapedName; if (!props.has(escapedName)) { @@ -51865,14 +53144,14 @@ var ts; function getConstraintFromIndexedAccess(type) { var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType); if (indexConstraint && indexConstraint !== type.indexType) { - var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint); + var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate); if (indexedAccess) { return indexedAccess; } } var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType); if (objectConstraint && objectConstraint !== type.objectType) { - return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType); + return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate); } return undefined; } @@ -51921,9 +53200,9 @@ var ts; function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; - if (t.flags & 63176704 /* Instantiable */) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; + if (t.flags & 465829888 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); @@ -51937,7 +53216,7 @@ var ts; } } } - else if (t.flags & 67238908 /* DisjointDomains */) { + else if (t.flags & 469892092 /* DisjointDomains */) { hasDisjointDomainType = true; } } @@ -51947,9 +53226,9 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { - var t = types_6[_a]; - if (t.flags & 67238908 /* DisjointDomains */) { + for (var _a = 0, types_7 = types; _a < types_7.length; _a++) { + var t = types_7[_a]; + if (t.flags & 469892092 /* DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -51959,7 +53238,7 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */)) { + if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } @@ -51981,9 +53260,12 @@ var ts; * circularly references the type variable. */ function getResolvedBaseConstraint(type) { + if (type.resolvedBaseConstraint) { + return type.resolvedBaseConstraint; + } var nonTerminating = false; - return type.resolvedBaseConstraint || - (type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type)); + var stack = []; + return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { @@ -51994,13 +53276,19 @@ var ts; // very high likelihood we're dealing with an infinite generic type that perpetually generates // new type identities as we descend into it. We stop the recursion here and mark this type // and the outer types as having circular constraints. + ts.tracing.instant("check" /* Check */, "getImmediateBaseConstraint_DepthLimit", { typeId: t.id, originalTypeId: type.id, depth: constraintDepth }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); nonTerminating = true; return t.immediateBaseConstraint = noConstraintType; } - constraintDepth++; - var result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false)); - constraintDepth--; + var result = void 0; + if (!isDeeplyNestedType(t, stack, stack.length)) { + stack.push(t); + constraintDepth++; + result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false)); + constraintDepth--; + stack.pop(); + } if (!popTypeResolution()) { if (t.flags & 262144 /* TypeParameter */) { var errorNode = getConstraintDeclaration(t); @@ -52034,8 +53322,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type_3 = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type_3 = types_8[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -52048,10 +53336,19 @@ var ts; if (t.flags & 4194304 /* Index */) { return keyofConstraintType; } + if (t.flags & 134217728 /* TemplateLiteral */) { + var types = t.types; + var constraints = ts.mapDefined(types, getBaseConstraint); + return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; + } + if (t.flags & 268435456 /* StringMapping */) { + var constraint = getBaseConstraint(t.type); + return constraint ? getStringMappingType(t.symbol, constraint) : stringType; + } if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); - var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType); + var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } if (t.flags & 16777216 /* Conditional */) { @@ -52118,7 +53415,7 @@ var ts; } function getResolvedApparentTypeOfMappedType(type) { var typeVariable = getHomomorphicTypeVariable(type); - if (typeVariable) { + if (typeVariable && !type.declaration.nameType) { var constraint = getConstraintOfTypeParameter(typeVariable); if (constraint && (isArrayType(constraint) || isTupleType(constraint))) { return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper)); @@ -52132,10 +53429,10 @@ var ts; * type itself. */ function getApparentType(type) { - var t = type.flags & 63176704 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type; + var t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type; return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 132 /* StringLike */ ? globalStringType : + t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) : t.flags & 528 /* BooleanLike */ ? globalBooleanType : @@ -52460,10 +53757,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 303 /* JSDocOptionalType */ + node.type && node.type.kind === 307 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 303 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -52482,7 +53779,10 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= getMinArgumentCount(signature, /*strongArityForUntypedJS*/ true); + // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used + // in grammar checks and checking for `void` too early results in parameter types widening too early + // and causes some noImplicitAny errors to be lost. + return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -52497,7 +53797,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 303 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -52579,7 +53879,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 190 /* LiteralType */) { + if (type && type.kind === 191 /* LiteralType */) { flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter @@ -52592,16 +53892,16 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 166 /* GetAccessor */ || declaration.kind === 167 /* SetAccessor */) && + if ((declaration.kind === 167 /* GetAccessor */ || declaration.kind === 168 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 166 /* GetAccessor */ ? 167 /* SetAccessor */ : 166 /* GetAccessor */; + var otherKind = declaration.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 165 /* Constructor */ ? + var classType = declaration.kind === 166 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -52666,11 +53966,11 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 162 /* PropertyDeclaration */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - return node.name.kind === 157 /* ComputedPropertyName */ + case 163 /* PropertyDeclaration */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + return node.name.kind === 158 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -52742,7 +54042,7 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 186 /* ThisType */ ? + return parameterName.kind === 187 /* ThisType */ ? createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } @@ -52785,7 +54085,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 165 /* Constructor */) { + if (declaration.kind === 166 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -52795,12 +54095,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 166 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 167 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 167 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -52890,7 +54190,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 165 /* Constructor */ || kind === 169 /* ConstructSignature */ || kind === 174 /* ConstructorType */; + var isConstructor = kind === 166 /* Constructor */ || kind === 170 /* ConstructSignature */ || kind === 175 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -52904,7 +54204,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 143 /* NumberKeyword */ : 146 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -52938,17 +54238,17 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 184 /* InferType */) { + if (declaration.parent.kind === 185 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo<infer T>'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. - var grandParent = declaration.parent.parent; - if (grandParent.kind === 172 /* TypeReference */) { + var _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1]; + if (grandParent.kind === 173 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); + var index = typeReference.typeArguments.indexOf(childTypeParameter); if (index < typeParameters.length) { var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); if (declaredConstraint) { @@ -52969,11 +54269,16 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 159 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 180 /* RestType */ || - grandParent.kind === 191 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 160 /* Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 181 /* RestType */ || + grandParent.kind === 192 /* NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } + // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' + // constraint. + else if (grandParent.kind === 194 /* TemplateLiteralTypeSpan */) { + inferences = ts.append(inferences, stringType); + } } } } @@ -52996,7 +54301,7 @@ var ts; if (type.flags & 1 /* Any */ && type !== errorType) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 189 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 190 /* MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -53005,7 +54310,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 158 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -53038,8 +54343,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -53085,8 +54390,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 172 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 177 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 173 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -53128,7 +54433,7 @@ var ts; return errorType; } } - if (node.kind === 172 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 173 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -53141,6 +54446,9 @@ var ts; } function getTypeAliasInstantiation(symbol, typeArguments) { var type = getDeclaredTypeOfSymbol(symbol); + if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) { + return getStringMappingType(symbol, typeArguments[0]); + } var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); @@ -53173,9 +54481,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 172 /* TypeReference */: + case 173 /* TypeReference */: return node.typeName; - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -53223,8 +54531,7 @@ var ts; } /** * A JSdoc TypeReference may be to a value, but resolve it as a type anyway. - * Note: If the value is imported from commonjs, it should really be an alias, - * but this function's special-case code fakes alias resolution as well. + * Example: import('./b').ConstructorFunction */ function getTypeFromJSDocValueReference(node, symbol) { var links = getNodeLinks(node); @@ -53232,19 +54539,9 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var decl = ts.getRootDeclaration(symbol.valueDeclaration); - var isRequireAlias = false; - if (ts.isVariableDeclaration(decl) && decl.initializer) { - var expr = decl.initializer; - // skip past entity names, eg `require("x").a.b.c` - while (ts.isPropertyAccessExpression(expr)) { - expr = expr.expression; - } - isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol; - } - var isImportTypeWithQualifier = node.kind === 192 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 195 /* ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} - if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier)) { + if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); } } @@ -53268,7 +54565,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 178 /* TupleType */ && node.elements.length === 1; + return node.kind === 179 /* TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -53277,9 +54574,9 @@ var ts; } function getConditionalFlowTypeOfType(type, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 307 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 311 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 183 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 184 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -53290,7 +54587,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 172 /* TypeReference */ || node.kind === 192 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 173 /* TypeReference */ || node.kind === 195 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -53403,9 +54700,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: return declaration; } } @@ -53526,11 +54823,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 179 /* OptionalType */: + case 180 /* OptionalType */: return 2 /* Optional */; - case 180 /* RestType */: + case 181 /* RestType */: return getRestTypeElementFlags(node); - case 191 /* NamedTupleMember */: + case 192 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; @@ -53548,14 +54845,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 191 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 192 /* NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 177 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 178 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 178 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 179 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -53564,18 +54861,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 185 /* ParenthesizedType */: - case 191 /* NamedTupleMember */: - case 172 /* TypeReference */: - case 181 /* UnionType */: - case 182 /* IntersectionType */: - case 188 /* IndexedAccessType */: - case 183 /* ConditionalType */: - case 187 /* TypeOperator */: - case 177 /* ArrayType */: - case 178 /* TupleType */: + case 186 /* ParenthesizedType */: + case 192 /* NamedTupleMember */: + case 173 /* TypeReference */: + case 182 /* UnionType */: + case 183 /* IntersectionType */: + case 189 /* IndexedAccessType */: + case 184 /* ConditionalType */: + case 188 /* TypeOperator */: + case 178 /* ArrayType */: + case 179 /* TupleType */: return isResolvedByTypeAlias(parent); - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: return true; } return false; @@ -53584,28 +54881,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 172 /* TypeReference */: + case 173 /* TypeReference */: return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 175 /* TypeQuery */: + case 176 /* TypeQuery */: return true; - case 187 /* TypeOperator */: - return node.operator !== 150 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 185 /* ParenthesizedType */: - case 179 /* OptionalType */: - case 191 /* NamedTupleMember */: - case 303 /* JSDocOptionalType */: - case 301 /* JSDocNullableType */: - case 302 /* JSDocNonNullableType */: - case 298 /* JSDocTypeExpression */: + case 188 /* TypeOperator */: + return node.operator !== 151 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 186 /* ParenthesizedType */: + case 180 /* OptionalType */: + case 192 /* NamedTupleMember */: + case 307 /* JSDocOptionalType */: + case 305 /* JSDocNullableType */: + case 306 /* JSDocNonNullableType */: + case 301 /* JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 180 /* RestType */: - return node.type.kind !== 177 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 181 /* UnionType */: - case 182 /* IntersectionType */: + case 181 /* RestType */: + return node.type.kind !== 178 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 182 /* UnionType */: + case 183 /* IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 188 /* IndexedAccessType */: + case 189 /* IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 183 /* ConditionalType */: + case 184 /* ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -53618,19 +54915,19 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 178 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 178 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 179 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 179 /* TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 177 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 141 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 142 /* ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } @@ -53727,7 +55024,9 @@ var ts; // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] var unionIndex = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); if (unionIndex >= 0) { - return mapType(elementTypes[unionIndex], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex, t)); }); + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + mapType(elementTypes[unionIndex], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex, t)); }) : + errorType; } // If there are no variadic elements with non-generic types, just create a type reference with the same target type. var spreadIndex = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */) && !(t.flags & 58982400 /* InstantiableNonPrimitive */) && !isGenericMappedType(t); }); @@ -53841,8 +55140,8 @@ var ts; } // We ignore 'never' types in unions if (!(flags & 131072 /* Never */)) { - includes |= flags & 71041023 /* IncludesMask */; - if (flags & 66846720 /* StructuredOrInstantiable */) + includes |= flags & 205258751 /* IncludesMask */; + if (flags & 469499904 /* StructuredOrInstantiable */) includes |= 262144 /* IncludesStructuredOrInstantiable */; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; @@ -53863,8 +55162,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var type = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -53893,8 +55192,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var target = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var target = types_11[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -53904,6 +55203,7 @@ var ts; // caps union types at 5000 unique literal types and 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) { + ts.tracing.instant("check" /* Check */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -53935,6 +55235,22 @@ var ts; } } } + function removeStringLiteralsMatchedByTemplateLiterals(types) { + var templates = ts.filter(types, isPatternLiteralType); + if (templates.length) { + var i = types.length; + var _loop_14 = function () { + i--; + var t = types[i]; + if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeSubtypeOf(t, template); })) { + ts.orderedRemoveItemAt(types, i); + } + }; + while (i > 0) { + _loop_14(); + } + } + } // We sort and deduplicate the constituent types based on object identity. If the subtypeReduction // flag is specified we also reduce the constituent type set to only include types that aren't subtypes // of other types. Subtype reduction is expensive for large union types and is possible only when union @@ -53961,6 +55277,9 @@ var ts; if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */)) { removeRedundantLiteralTypes(typeSet, includes); } + if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + removeStringLiteralsMatchedByTemplateLiterals(typeSet); + } break; case 2 /* Subtype */: if (!removeSubtypes(typeSet, !(includes & 262144 /* IncludesStructuredOrInstantiable */))) { @@ -53974,7 +55293,7 @@ var ts; neverType; } } - var objectFlags = (includes & 66994211 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */) | + var objectFlags = (includes & 469647395 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 268435456 /* ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments); } @@ -54066,15 +55385,15 @@ var ts; } typeSet.set(type.id.toString(), type); } - includes |= flags & 71041023 /* IncludesMask */; + includes |= flags & 205258751 /* IncludesMask */; } return includes; } // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var type = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var type = types_12[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -54112,6 +55431,31 @@ var ts; } return true; } + /** + * Returns `true` if the intersection of the template literals and string literals is the empty set, eg `get${string}` & "setX", and should reduce to `never` + */ + function extractRedundantTemplateLiterals(types) { + var i = types.length; + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + while (i > 0) { + i--; + var t = types[i]; + if (!(t.flags & 134217728 /* TemplateLiteral */)) + continue; + for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { + var t2 = literals_1[_i]; + if (isTypeSubtypeOf(t2, t)) { + // eg, ``get${T}` & "getX"` is just `"getX"` + ts.orderedRemoveItemAt(types, i); + break; + } + else if (isPatternLiteralType(t)) { + return true; + } + } + } + return false; + } function extractIrreducible(types, flag) { if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { for (var i = 0; i < types.length; i++) { @@ -54200,12 +55544,15 @@ var ts; // a non-primitive type and a type known to be primitive. if (includes & 131072 /* Never */ || strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (67238908 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 132 /* StringLike */ && includes & (67238908 /* DisjointDomains */ & ~132 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (67238908 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (67238908 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (67238908 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (67238908 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || + includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || + includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || + includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || + includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || + includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + return neverType; + } + if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } if (includes & 1 /* Any */) { @@ -54249,9 +55596,7 @@ var ts; // 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); + if (!checkCrossProductUnion(typeSet)) { return errorType; } var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; }); @@ -54266,6 +55611,15 @@ var ts; } return result; } + function checkCrossProductUnion(types) { + var size = ts.reduceLeft(types, function (n, t) { return n * (t.flags & 1048576 /* Union */ ? t.types.length : t.flags & 131072 /* Never */ ? 0 : 1); }, 1); + if (size >= 100000) { + ts.tracing.instant("check" /* Check */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); + return false; + } + return true; + } function getTypeFromIntersectionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -54285,6 +55639,24 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } + function getIndexTypeForMappedType(type, noIndexSignatures) { + var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 /* Any */ | 4 /* String */)); }); + var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType); + return nameType ? + mapType(constraint, function (t) { return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); }) : + constraint; + } + // Ordinarily we reduce a keyof M where M is a mapped type { [P in K as N<P>]: X } to simply N<K>. This however presumes + // that N distributes over union types, i.e. that N<A | B | C> is equivalent to N<A> | N<B> | N<C>. That presumption is + // generally true, except when N is a non-distributive conditional type or an instantiable type with non-distributive + // conditional type as a constituent. In those cases, we cannot reduce keyof M and need to preserve it as is. + function isNonDistributiveNameType(type) { + return !!(type && (type.flags & 16777216 /* Conditional */ && !type.root.isDistributive || + type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && ts.some(type.types, isNonDistributiveNameType) || + type.flags & (4194304 /* Index */ | 268435456 /* StringMapping */) && isNonDistributiveNameType(type.type) || + type.flags & 8388608 /* IndexedAccess */ && isNonDistributiveNameType(type.indexType) || + type.flags & 33554432 /* Substitution */ && isNonDistributiveNameType(type.substitute))); + } function getLiteralTypeFromPropertyName(name) { if (ts.isPrivateIdentifier(name)) { return neverType; @@ -54328,8 +55700,8 @@ var ts; type = getReducedType(type); return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 /* Any */ | 4 /* String */)); }) : + type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && isNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) : + ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : @@ -54353,15 +55725,15 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 137 /* KeyOfKeyword */: + case 138 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 150 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 147 /* SymbolKeyword */ + case 151 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 148 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 141 /* ReadonlyKeyword */: + case 142 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -54370,12 +55742,115 @@ var ts; } return links.resolvedType; } - function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments) { + function getTypeFromTemplateTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getTemplateLiteralType(__spreadArrays([node.head.text], ts.map(node.templateSpans, function (span) { return span.literal.text; })), ts.map(node.templateSpans, function (span) { return getTypeFromTypeNode(span.type); })); + } + return links.resolvedType; + } + function getTemplateLiteralType(texts, types) { + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + if (unionIndex >= 0) { + return checkCrossProductUnion(types) ? + mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : + errorType; + } + if (ts.contains(types, wildcardType)) { + return wildcardType; + } + var newTypes = []; + var newTexts = []; + var text = texts[0]; + if (!addSpans(texts, types)) { + return stringType; + } + if (newTypes.length === 0) { + return getLiteralType(text); + } + newTexts.push(text); + var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var type = templateLiteralTypes.get(id); + if (!type) { + templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); + } + return type; + function addSpans(texts, types) { + for (var i = 0; i < types.length; i++) { + var t = types[i]; + if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + text += getTemplateStringForType(t) || ""; + text += texts[i + 1]; + } + else if (t.flags & 134217728 /* TemplateLiteral */) { + text += t.texts[0]; + if (!addSpans(t.texts, t.types)) + return false; + text += texts[i + 1]; + } + else if (isGenericIndexType(t) || isPatternLiteralPlaceholderType(t)) { + newTypes.push(t); + newTexts.push(text); + text = texts[i + 1]; + } + else { + return false; + } + } + return true; + } + } + function getTemplateStringForType(type) { + return type.flags & 128 /* StringLiteral */ ? type.value : + type.flags & 256 /* NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & 512 /* BooleanLiteral */ ? type.intrinsicName : + type.flags & 65536 /* Null */ ? "null" : + type.flags & 32768 /* Undefined */ ? "undefined" : + undefined; + } + function createTemplateLiteralType(texts, types) { + var type = createType(134217728 /* TemplateLiteral */); + type.texts = texts; + type.types = types; + return type; + } + function getStringMappingType(symbol, type) { + return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : + type.flags & 128 /* StringLiteral */ ? getLiteralType(applyStringMapping(symbol, type.value)) : + type; + } + function applyStringMapping(symbol, str) { + switch (intrinsicTypeKinds.get(symbol.escapedName)) { + case 0 /* Uppercase */: return str.toUpperCase(); + case 1 /* Lowercase */: return str.toLowerCase(); + case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + } + return str; + } + function getStringMappingTypeForGenericType(symbol, type) { + var id = getSymbolId(symbol) + "," + getTypeId(type); + var result = stringMappingTypes.get(id); + if (!result) { + stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); + } + return result; + } + function createStringMappingType(symbol, type) { + var result = createType(268435456 /* StringMapping */); + result.symbol = symbol; + result.type = type; + return result; + } + function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) { var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; + type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined; return type; } /** @@ -54400,13 +55875,13 @@ var ts; if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & 465829888 /* Instantiable */) { return isJSLiteralType(getResolvedBaseConstraint(type)); } return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 199 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -54421,15 +55896,15 @@ var ts; || !ts.isCallLikeExpression(ts.findAncestor(node, function (n) { return !ts.isAccessExpression(n); }) || node.parent) && ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); }); } - function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, reportDeprecated) { - var _a, _b; - var accessExpression = accessNode && accessNode.kind === 199 /* ElementAccessExpression */ ? accessNode : undefined; + function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) { + var _a; + var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { - if (reportDeprecated && accessNode && ((_a = prop.valueDeclaration) === null || _a === void 0 ? void 0 : _a.flags) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { - var deprecatedNode = (_b = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _b !== void 0 ? _b : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); + if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { + var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); errorOrSuggestion(/* isError */ false, deprecatedNode, ts.Diagnostics._0_is_deprecated, propName); } if (accessExpression) { @@ -54461,10 +55936,13 @@ var ts; } } errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */)); - return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; }); + return mapType(objectType, function (t) { + var restType = getRestTypeOfTupleType(t) || undefinedType; + return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType; + }); } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { + if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { return objectType; } @@ -54480,10 +55958,10 @@ var ts; if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return indexInfo.type; + return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return indexInfo.type; + return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } if (indexType.flags & 131072 /* Never */) { return neverType; @@ -54567,11 +56045,17 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 199 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 188 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 157 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 189 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 158 /* ComputedPropertyName */ ? accessNode.expression : accessNode; } + function isPatternLiteralPlaceholderType(type) { + return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1 /* Any */); + } + function isPatternLiteralType(type) { + return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + } function isGenericObjectType(type) { if (type.flags & 3145728 /* UnionOrIntersection */) { if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { @@ -54590,7 +56074,7 @@ var ts; } return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); } - return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */)); + return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type); } function isThisTypeParameter(type) { return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); @@ -54643,7 +56127,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 63176704 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -54706,8 +56190,9 @@ var ts; var templateMapper = combineTypeMappers(objectType.mapper, mapper); return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - function getIndexedAccessType(objectType, indexType, accessNode, aliasSymbol, aliasTypeArguments) { - return getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, 0 /* None */, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); + function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) { + if (accessFlags === void 0) { accessFlags = 0 /* None */; } + return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { @@ -54721,11 +56206,14 @@ var ts; return false; }); } - function getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) { + function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } + var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate || + (!!compilerOptions.noUncheckedIndexedAccess && + (accessFlags & (2 /* Writing */ | 16 /* ExpressionPosition */)) === 16 /* ExpressionPosition */); // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { @@ -54737,17 +56225,17 @@ var ts; // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 188 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 189 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var id = objectType.id + "," + indexType.id; + var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : ""); var type = indexedAccessTypes.get(id); if (!type) { - indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments)); + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined)); } return type; } @@ -54760,7 +56248,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, indexType, wasMissingProp, accessNode, accessFlags); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined); if (propType) { propTypes.push(propType); } @@ -54776,9 +56264,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 2 /* Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + return accessFlags & 2 /* Writing */ + ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) + : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */, /* reportDeprecated */ true); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */, shouldIncludeUndefined, /* reportDeprecated */ true); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -54786,7 +56276,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + var resolved = getIndexedAccessType(objectType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? @@ -54821,7 +56311,7 @@ var ts; function getConditionalType(root, mapper) { var result; var extraTypes; - var _loop_14 = function () { + var _loop_15 = function () { var checkType = instantiateType(root.checkType, mapper); var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); var extendsType = instantiateType(root.extendsType, mapper); @@ -54854,11 +56344,11 @@ var ts; if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything if (checkType.flags & 1 /* Any */) { - (extraTypes || (extraTypes = [])).push(instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper)); + (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. - var falseType_1 = root.falseType; + var falseType_1 = getTypeFromTypeNode(root.node.falseType); if (falseType_1.flags & 16777216 /* Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { @@ -54866,7 +56356,7 @@ var ts; return "continue"; } } - result = instantiateTypeWithoutDepthIncrease(falseType_1, mapper); + result = instantiateType(falseType_1, mapper); return "break"; } // Return trueType for a definitely true extends check. We check instantiations of the two @@ -54875,7 +56365,7 @@ var ts; // type Foo<T extends { x: any }> = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { - result = instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper); + result = instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper); return "break"; } } @@ -54895,7 +56385,7 @@ var ts; // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for // purposes of resolution. This means such types aren't subject to the instatiation depth limiter. while (true) { - var state_4 = _loop_14(); + var state_4 = _loop_15(); if (typeof state_4 === "object") return state_4.value; if (state_4 === "break") @@ -54904,13 +56394,13 @@ var ts; return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result; } function getTrueTypeFromConditionalType(type) { - return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(type.root.trueType, type.mapper)); + return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(getTypeFromTypeNode(type.root.node.trueType), type.mapper)); } function getFalseTypeFromConditionalType(type) { - return type.resolvedFalseType || (type.resolvedFalseType = instantiateType(type.root.falseType, type.mapper)); + return type.resolvedFalseType || (type.resolvedFalseType = instantiateType(getTypeFromTypeNode(type.root.node.falseType), type.mapper)); } function getInferredTrueTypeFromConditionalType(type) { - return type.resolvedInferredTrueType || (type.resolvedInferredTrueType = type.combinedMapper ? instantiateType(type.root.trueType, type.combinedMapper) : getTrueTypeFromConditionalType(type)); + return type.resolvedInferredTrueType || (type.resolvedInferredTrueType = type.combinedMapper ? instantiateType(getTypeFromTypeNode(type.root.node.trueType), type.combinedMapper) : getTrueTypeFromConditionalType(type)); } function getInferTypeParameters(node) { var result; @@ -54935,8 +56425,6 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - trueType: getTypeFromTypeNode(node.trueType), - falseType: getTypeFromTypeNode(node.falseType), isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, @@ -54994,7 +56482,13 @@ var ts; var current = void 0; while (current = nameStack.shift()) { var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; - var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); + // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` + // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from + // the `exports` lookup process that only looks up namespace members which is used for most type references + var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace)); + var next = node.isTypeOf + ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText) + : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); return links.resolvedType = errorType; @@ -55053,7 +56547,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 141 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142 /* ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -55065,12 +56559,7 @@ var ts; return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); - } - function isSinglePropertyAnonymousObjectType(type) { - return !!(type.flags & 524288 /* Object */) && - !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && - (ts.length(getPropertiesOfType(type)) === 1 || ts.every(getPropertiesOfType(type), function (p) { return !!(p.flags & 16777216 /* Optional */); })); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { if (type.types.length === 2) { @@ -55079,10 +56568,10 @@ var ts; if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { return isEmptyObjectType(firstType) ? firstType : isEmptyObjectType(secondType) ? secondType : emptyObjectType; } - if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType) && isSinglePropertyAnonymousObjectType(secondType)) { + if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType)) { return getAnonymousPartialType(secondType); } - if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType) && isSinglePropertyAnonymousObjectType(firstType)) { + if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType)) { return getAnonymousPartialType(firstType); } } @@ -55133,16 +56622,20 @@ var ts; if (merged) { return getSpreadType(merged, right, symbol, objectFlags, readonly); } - return mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }); + return checkCrossProductUnion([left, right]) + ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) + : errorType; } if (right.flags & 1048576 /* Union */) { var merged = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); if (merged) { return getSpreadType(left, merged, symbol, objectFlags, readonly); } - return mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }); + return checkCrossProductUnion([left, right]) + ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) + : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -55303,7 +56796,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 250 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 253 /* InterfaceDeclaration */)) { if (!ts.hasSyntacticModifier(container, 32 /* Static */) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -55338,17 +56831,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 185 /* ParenthesizedType */: + case 186 /* ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 178 /* TupleType */: + case 179 /* TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 180 /* RestType */ || node.kind === 191 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 181 /* RestType */ || node.kind === 192 /* NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 177 /* ArrayType */: + case 178 /* ArrayType */: return node.elementType; } return undefined; @@ -55366,94 +56859,98 @@ var ts; function getTypeFromTypeNodeWorker(node) { switch (node.kind) { case 128 /* AnyKeyword */: - case 299 /* JSDocAllType */: - case 300 /* JSDocUnknownType */: + case 303 /* JSDocAllType */: + case 304 /* JSDocUnknownType */: return anyType; - case 151 /* UnknownKeyword */: + case 152 /* UnknownKeyword */: return unknownType; - case 146 /* StringKeyword */: + case 147 /* StringKeyword */: return stringType; - case 143 /* NumberKeyword */: + case 144 /* NumberKeyword */: return numberType; - case 154 /* BigIntKeyword */: + case 155 /* BigIntKeyword */: return bigintType; case 131 /* BooleanKeyword */: return booleanType; - case 147 /* SymbolKeyword */: + case 148 /* SymbolKeyword */: return esSymbolType; case 113 /* VoidKeyword */: return voidType; - case 149 /* UndefinedKeyword */: + case 150 /* UndefinedKeyword */: return undefinedType; case 103 /* NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 140 /* NeverKeyword */: + case 141 /* NeverKeyword */: return neverType; - case 144 /* ObjectKeyword */: + case 145 /* ObjectKeyword */: return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 186 /* ThisType */: + case 136 /* IntrinsicKeyword */: + return intrinsicMarkerType; + case 187 /* ThisType */: case 107 /* ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 190 /* LiteralType */: + case 191 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 172 /* TypeReference */: + case 173 /* TypeReference */: return getTypeFromTypeReference(node); - case 171 /* TypePredicate */: + case 172 /* TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 175 /* TypeQuery */: + case 176 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 177 /* ArrayType */: - case 178 /* TupleType */: + case 178 /* ArrayType */: + case 179 /* TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 179 /* OptionalType */: + case 180 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 181 /* UnionType */: + case 182 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 182 /* IntersectionType */: + case 183 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 301 /* JSDocNullableType */: + case 305 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 303 /* JSDocOptionalType */: + case 307 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 191 /* NamedTupleMember */: + case 192 /* NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 185 /* ParenthesizedType */: - case 302 /* JSDocNonNullableType */: - case 298 /* JSDocTypeExpression */: + case 186 /* ParenthesizedType */: + case 306 /* JSDocNonNullableType */: + case 301 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 180 /* RestType */: + case 181 /* RestType */: return getTypeFromRestTypeNode(node); - case 305 /* JSDocVariadicType */: + case 309 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 176 /* TypeLiteral */: - case 308 /* JSDocTypeLiteral */: - case 304 /* JSDocFunctionType */: - case 309 /* JSDocSignature */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 177 /* TypeLiteral */: + case 312 /* JSDocTypeLiteral */: + case 308 /* JSDocFunctionType */: + case 313 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 187 /* TypeOperator */: + case 188 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 188 /* IndexedAccessType */: + case 189 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 189 /* MappedType */: + case 190 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 183 /* ConditionalType */: + case 184 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 184 /* InferType */: + case 185 /* InferType */: return getTypeFromInferTypeNode(node); - case 192 /* ImportType */: + case 193 /* TemplateLiteralType */: + return getTypeFromTemplateTypeNode(node); + case 195 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. case 78 /* Identifier */: - case 156 /* QualifiedName */: - case 198 /* PropertyAccessExpression */: + case 157 /* QualifiedName */: + case 201 /* PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -55607,9 +57104,10 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper) { - var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; var declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); + var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : + type.objectFlags & 64 /* Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -55626,10 +57124,6 @@ var ts; ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) : typeParameters; links.outerTypeParameters = typeParameters; - if (typeParameters.length) { - links.instantiations = new ts.Map(); - links.instantiations.set(getTypeListId(typeParameters), target); - } } if (typeParameters.length) { // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the @@ -55638,22 +57132,26 @@ var ts; var combinedMapper_1 = combineTypeMappers(type.mapper, mapper); var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); }); var id = getTypeListId(typeArguments); - var result = links.instantiations.get(id); + if (!target.instantiations) { + target.instantiations = new ts.Map(); + target.instantiations.set(getTypeListId(typeParameters), target); + } + var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); - links.instantiations.set(id, result); + target.instantiations.set(id, result); } return result; } return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 156 /* QualifiedName */ || - node.parent.kind === 172 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 192 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.kind === 157 /* QualifiedName */ || + node.parent.kind === 173 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 195 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -55662,7 +57160,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 227 /* Block */ || n.kind === 183 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 230 /* Block */ || n.kind === 184 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -55671,12 +57169,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 186 /* ThisType */: + case 187 /* ThisType */: return !!tp.isThisType; case 78 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 175 /* TypeQuery */: + case 176 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -55709,13 +57207,18 @@ var ts; if (typeVariable !== mappedTypeVariable) { return mapType(getReducedType(mappedTypeVariable), function (t) { if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t !== errorType) { - if (isGenericTupleType(t)) { - return instantiateMappedGenericTupleType(t, type, typeVariable, mapper); + if (!type.declaration.nameType) { + if (isArrayType(t)) { + return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); + } + if (isGenericTupleType(t)) { + return instantiateMappedGenericTupleType(t, type, typeVariable, mapper); + } + if (isTupleType(t)) { + return instantiateMappedTupleType(t, type, prependTypeMapping(typeVariable, t, mapper)); + } } - var replacementMapper = prependTypeMapping(typeVariable, t, mapper); - return isArrayType(t) ? instantiateMappedArrayType(t, type, replacementMapper) : - isTupleType(t) ? instantiateMappedTupleType(t, type, replacementMapper) : - instantiateAnonymousType(type, replacementMapper); + return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper)); } return t; }); @@ -55824,6 +57327,7 @@ var ts; // We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing // with a combination of infinite generic types that perpetually generate new type identities. We stop // the recursion here by yielding the error type. + ts.tracing.instant("check" /* Check */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -55834,16 +57338,6 @@ var ts; instantiationDepth--; return result; } - /** - * This can be used to avoid the penalty on instantiation depth for types which result from immediate - * simplification. It essentially removes the depth increase done in `instantiateType`. - */ - function instantiateTypeWithoutDepthIncrease(type, mapper) { - instantiationDepth--; - var result = instantiateType(type, mapper); - instantiationDepth++; - return result; - } function instantiateTypeWorker(type, mapper) { var flags = type.flags; if (flags & 262144 /* TypeParameter */) { @@ -55872,8 +57366,14 @@ var ts; if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); } + if (flags & 134217728 /* TemplateLiteral */) { + return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); + } + if (flags & 268435456 /* StringMapping */) { + return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); + } if (flags & 8388608 /* IndexedAccess */) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), /*accessNode*/ undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (flags & 16777216 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); @@ -55919,35 +57419,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 164 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 164 /* MethodDeclaration */: - case 248 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 165 /* MethodDeclaration */: + case 251 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 278 /* JsxAttributes */: + case 281 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 277 /* JsxAttribute */: { + case 280 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 280 /* JsxExpression */: { + case 283 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g <div x={} />) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -55966,7 +57466,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 206 /* ArrowFunction */) { + if (node.kind !== 209 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -55979,7 +57479,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 227 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 230 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -56035,7 +57535,7 @@ var ts; source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : - hasBaseType(source, getTargetType(target)); + hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** * This is *not* a bi-directional relationship. @@ -56082,23 +57582,23 @@ var ts; return true; } switch (node.kind) { - case 280 /* JsxExpression */: - case 204 /* ParenthesizedExpression */: + case 283 /* JsxExpression */: + case 207 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: switch (node.operatorToken.kind) { case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 278 /* JsxAttributes */: + case 281 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -56298,7 +57798,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 280 /* JsxExpression */: + case 283 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -56307,18 +57807,15 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 270 /* JsxElement */: - case 271 /* JsxSelfClosingElement */: - case 274 /* JsxFragment */: + case 273 /* JsxElement */: + case 274 /* JsxSelfClosingElement */: + case 277 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: return ts.Debug.assertNever(child, "Found invalid jsx child"); } } - function getSemanticJsxChildren(children) { - return ts.filter(children, function (i) { return !ts.isJsxText(i) || !i.containsOnlyTriviaWhiteSpaces; }); - } function elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer) { var result = elaborateElementwise(generateJsxAttributes(node), source, target, relation, containingMessageChain, errorOutputContainer); var invalidTextDiagnostic; @@ -56328,7 +57825,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenNameType = getLiteralType(childrenPropName); var childrenTargetType = getIndexedAccessType(target, childrenNameType); - var validChildren = getSemanticJsxChildren(containingElement.children); + var validChildren = ts.getSemanticJsxChildren(containingElement.children); if (!ts.length(validChildren)) { return result; } @@ -56460,11 +57957,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 167 /* SetAccessor */: return [3 /*break*/, 2]; - case 166 /* GetAccessor */: return [3 /*break*/, 2]; - case 164 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 286 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 285 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 168 /* SetAccessor */: return [3 /*break*/, 2]; + case 167 /* GetAccessor */: return [3 /*break*/, 2]; + case 165 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 289 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 288 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -56541,8 +58038,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 164 /* MethodDeclaration */ && - kind !== 163 /* MethodSignature */ && kind !== 165 /* Constructor */; + var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 165 /* MethodDeclaration */ && + kind !== 164 /* MethodSignature */ && kind !== 166 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -56563,34 +58060,36 @@ var ts; var paramCount = sourceRestType || targetRestType ? Math.min(sourceCount, targetCount) : Math.max(sourceCount, targetCount); var restIndex = sourceRestType || targetRestType ? paramCount - 1 : -1; for (var i = 0; i < paramCount; i++) { - var sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : getTypeAtPosition(source, i); - var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : getTypeAtPosition(target, i); - // In order to ensure that any generic type Foo<T> is at least co-variant with respect to T no matter - // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, - // they naturally relate only contra-variantly). However, if the source and target parameters both have - // function types with a single call signature, we know we are relating two callback parameters. In - // that case it is sufficient to only relate the parameters of the signatures co-variantly because, - // similar to return values, callback parameters are output positions. This means that a Promise<T>, - // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) - // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); - var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); - // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; - } - if (!related) { - if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); + var sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : tryGetTypeAtPosition(source, i); + var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : tryGetTypeAtPosition(target, i); + if (sourceType && targetType) { + // In order to ensure that any generic type Foo<T> is at least co-variant with respect to T no matter + // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, + // they naturally relate only contra-variantly). However, if the source and target parameters both have + // function types with a single call signature, we know we are relating two callback parameters. In + // that case it is sufficient to only relate the parameters of the signatures co-variantly because, + // similar to return values, callback parameters are output positions. This means that a Promise<T>, + // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) + // with respect to T. + var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && + (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); + var related = callbacks ? + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void + if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* False */; } - return 0 /* False */; + if (!related) { + if (reportErrors) { + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); + } + return 0 /* False */; + } + result &= related; } - result &= related; } if (!(checkMode & 4 /* IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error @@ -56733,7 +58232,7 @@ var ts; return true; if (t & 131072 /* Never */) return false; - if (s & 132 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* StringLike */ && t & 4 /* String */) return true; if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && @@ -56795,7 +58294,7 @@ var ts; } else { if (!(source.flags & 3145728 /* UnionOrIntersection */) && !(target.flags & 3145728 /* UnionOrIntersection */) && - source.flags !== target.flags && !(source.flags & 66584576 /* Substructure */)) + source.flags !== target.flags && !(source.flags & 469237760 /* Substructure */)) return false; } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { @@ -56804,7 +58303,7 @@ var ts; return !!(related & 1 /* Succeeded */); } } - if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -56857,6 +58356,7 @@ var ts; reportIncompatibleStack(); } if (overflow) { + ts.tracing.instant("check" /* Check */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -57231,7 +58731,7 @@ var ts; // breaking the intersection apart. result = someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); } - if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (!result && (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) { resetErrorInfo(saveErrorInfo); } @@ -57329,7 +58829,7 @@ var ts; } function isIdenticalTo(source, target) { var flags = source.flags & target.flags; - if (!(flags & 66584576 /* Substructure */)) { + if (!(flags & 469237760 /* Substructure */)) { return 0 /* False */; } if (flags & 3145728 /* UnionOrIntersection */) { @@ -57365,7 +58865,7 @@ var ts; reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; } - var _loop_15 = function (prop) { + var _loop_16 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -57428,7 +58928,7 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_5 = _loop_15(prop); + var state_5 = _loop_16(prop); if (typeof state_5 === "object") return state_5.value; } @@ -57614,7 +59114,7 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i]) { - return 1 /* Maybe */; + return 3 /* Maybe */; } } if (depth === 100) { @@ -57642,7 +59142,16 @@ var ts; return originalHandler(onlyUnreliable); }; } - var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 1 /* Maybe */; + if (expandingFlags === 3 /* Both */) { + ts.tracing.instant("check" /* Check */, "recursiveTypeRelatedTo_DepthLimit", { + sourceId: source.id, + sourceIdStack: sourceStack.map(function (t) { return t.id; }), + targetId: target.id, + targetIdStack: targetStack.map(function (t) { return t.id; }), + depth: depth, + }); + } + var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */; if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } @@ -57650,9 +59159,12 @@ var ts; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { - // If result is definitely true, record all maybe keys as having succeeded - for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + if (result === -1 /* True */ || result === 3 /* Maybe */) { + // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe + // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. + for (var i = maybeStart; i < maybeCount; i++) { + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + } } maybeCount = maybeStart; } @@ -57666,6 +59178,12 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { + ts.tracing.push("check" /* Check */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState); + ts.tracing.pop(); + return result; + } + function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) { if (intersectionState & 4 /* PropertyCheck */) { return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); } @@ -57712,7 +59230,7 @@ var ts; !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Maybe */; + return 1 /* Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -57727,7 +59245,7 @@ var ts; } if (target.flags & 262144 /* TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) { + if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); @@ -57777,14 +59295,14 @@ var ts; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { var accessFlags = 2 /* Writing */ | (baseObjectType !== objectType ? 1 /* NoIndexSignatures */ : 0); - var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, /*accessNode*/ undefined, accessFlags); + var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, accessFlags); if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) { return result; } } } } - else if (isGenericMappedType(target)) { + else if (isGenericMappedType(target) && !target.declaration.nameType) { // A source type T is related to a target type { [P in X]: T[P] } var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); @@ -57826,6 +59344,15 @@ var ts; } } } + else if (target.flags & 134217728 /* TemplateLiteral */ && source.flags & 128 /* StringLiteral */) { + if (isPatternLiteralType(target)) { + // match all non-`string` segments + var result_8 = inferLiteralsFromTemplateLiteralType(source, target); + if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) { + return -1 /* True */; + } + } + } if (source.flags & 8650752 /* TypeVariable */) { if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { // A type S[K] is related to a type T[J] if S is related to T and K is related to J. @@ -57864,6 +59391,35 @@ var ts; return result; } } + else if (source.flags & 134217728 /* TemplateLiteral */) { + if (target.flags & 134217728 /* TemplateLiteral */ && + source.texts.length === target.texts.length && + source.types.length === target.types.length && + ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && + ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { + return -1 /* True */; + } + var constraint = getBaseConstraintOfType(source); + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) { + resetErrorInfo(saveErrorInfo); + return result; + } + } + else if (source.flags & 268435456 /* StringMapping */) { + if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { + if (result = isRelatedTo(source.type, target.type, reportErrors)) { + resetErrorInfo(saveErrorInfo); + return result; + } + } + else { + var constraint = getBaseConstraintOfType(source); + if (constraint && (result = isRelatedTo(constraint, target, reportErrors))) { + resetErrorInfo(saveErrorInfo); + return result; + } + } + } else if (source.flags & 16777216 /* Conditional */) { if (target.flags & 16777216 /* Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if @@ -57942,7 +59498,7 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Maybe */; + return 1 /* Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { @@ -57999,9 +59555,9 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) { var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); if (objectOnlyTarget.flags & 1048576 /* Union */) { - var result_8 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_8) { - return result_8; + var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_9) { + return result_9; } } } @@ -58068,12 +59624,14 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_9; + var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_9 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); - return result_9 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); + if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); + } } } return 0 /* False */; @@ -58103,6 +59661,7 @@ var ts; numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. + ts.tracing.instant("check" /* Check */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); return 0 /* False */; } } @@ -58121,11 +59680,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_16 = function (combination) { + var _loop_17 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_17 = function (i) { + var _loop_18 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -58141,7 +59700,7 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_7 = _loop_17(i); + var state_7 = _loop_18(i); switch (state_7) { case "continue-outer": continue outer; } @@ -58155,7 +59714,7 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_6 = _loop_16(combination); + var state_6 = _loop_17(combination); if (typeof state_6 === "object") return state_6.value; } @@ -58211,7 +59770,7 @@ var ts; ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); - var result_10 = unionParent ? 0 /* False */ : -1 /* True */; + var result_11 = unionParent ? 0 /* False */ : -1 /* True */; var targetTypes = links.deferralConstituents; for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { var targetType = targetTypes_3[_i]; @@ -58221,7 +59780,7 @@ var ts; // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); } - result_10 &= related; + result_11 &= related; } else { if (related) { @@ -58229,17 +59788,17 @@ var ts; } } } - if (unionParent && !result_10 && targetIsOptional) { - result_10 = isRelatedTo(source, undefinedType); + if (unionParent && !result_11 && targetIsOptional) { + result_11 = isRelatedTo(source, undefinedType); } - if (unionParent && !result_10 && reportErrors) { + if (unionParent && !result_11 && reportErrors) { // The easiest way to get the right errors here is to un-defer (which may be costly) // If it turns out this is too costly too often, we can replicate the error handling logic within // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union // type on which to hand discriminable properties, which we are expressly trying to avoid here) return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); } - return result_10; + return result_11; } else { return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState); @@ -58499,6 +60058,7 @@ var ts; return result; } function signaturesRelatedTo(source, target, kind, reportErrors) { + var _a, _b; if (relation === identityRelation) { return signaturesIdenticalTo(source, target, kind); } @@ -58529,7 +60089,9 @@ var ts; var result = -1 /* True */; var saveErrorInfo = captureErrorCalculationState(); var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; - if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { + var sourceObjectFlags = ts.getObjectFlags(source); + var targetObjectFlags = ts.getObjectFlags(target); + if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -58549,15 +60111,26 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); + var sourceSignature = ts.first(sourceSignatures); + var targetSignature = ts.first(targetSignatures); + result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); + if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 166 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166 /* Constructor */)) { + var constructSignatureToString = function (signature) { + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + }; + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); + reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); + return result; + } } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { var t = targetSignatures_1[_i]; // Only elaborate errors from the first failure var shouldElaborateErrors = reportErrors; - for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { - var s = sourceSignatures_1[_a]; + for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) { + var s = sourceSignatures_1[_c]; var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; @@ -58721,13 +60294,13 @@ var ts; if (type.flags & 3145728 /* UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & 465829888 /* Instantiable */) { var constraint = getConstraintOfType(type); - if (constraint) { + if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type); + return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */); } function getBestMatchingType(source, target, isRelatedTo) { if (isRelatedTo === void 0) { isRelatedTo = compareTypesAssignable; } @@ -58761,8 +60334,18 @@ var ts; } } var match = discriminable.indexOf(/*searchElement*/ true); + if (match === -1) { + return defaultValue; + } // make sure exactly 1 matches before returning it - return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; + var nextMatch = discriminable.indexOf(/*searchElement*/ true, match + 1); + while (nextMatch !== -1) { + if (!isTypeIdenticalTo(target.types[match], target.types[nextMatch])) { + return defaultValue; + } + nextMatch = discriminable.indexOf(/*searchElement*/ true, nextMatch + 1); + } + return target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -58811,13 +60394,15 @@ var ts; // instantiations of the generic type for type arguments with known relations. The function // returns the emptyArray singleton when invoked recursively for the given generic type. function getVariancesWorker(typeParameters, cache, createMarkerType) { + var _a, _b, _c; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var variances = cache.variances; if (!variances) { + ts.tracing.push("check" /* Check */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_18 = function (tp) { + var _loop_19 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -58849,9 +60434,10 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_18(tp); + _loop_19(tp); } cache.variances = variances; + ts.tracing.pop(); } return variances; } @@ -58982,58 +60568,54 @@ var ts; // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]` // in such cases we need to terminate the expansion, and we do so here. function isDeeplyNestedType(type, stack, depth) { - // We track all object types that have an associated symbol (representing the origin of the type) - if (depth >= 5 && type.flags & 524288 /* Object */) { - if (!isObjectOrArrayLiteralType(type)) { - var symbol = type.symbol; - if (symbol) { - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 524288 /* Object */ && t.symbol === symbol) { - count++; - if (count >= 5) - return true; - } - } - } - } - if (ts.getObjectFlags(type) && 4 /* Reference */ && !!type.node) { - var root = type.target; + if (depth >= 5) { + var identity_1 = getRecursionIdentity(type); + if (identity_1) { var count = 0; for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (ts.getObjectFlags(t) && 4 /* Reference */ && !!t.node && t.target === root) { + if (getRecursionIdentity(stack[i]) === identity_1) { count++; - if (count >= 5) + if (count >= 5) { return true; + } } } } } - if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { - var root = getRootObjectTypeFromIndexedAccessChain(type); - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (getRootObjectTypeFromIndexedAccessChain(t) === root) { - count++; - if (count >= 5) - return true; - } - } - } return false; } - /** - * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A - */ - function getRootObjectTypeFromIndexedAccessChain(type) { - var t = type; - while (t.flags & 8388608 /* IndexedAccess */) { - t = t.objectType; + // Types with constituents that could circularly reference the type have a recursion identity. The recursion + // identity is some object that is common to instantiations of the type with the same origin. + function getRecursionIdentity(type) { + if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + // Deferred type references are tracked through their associated AST node. This gives us finer + // granularity than using their associated target because each manifest type reference has a + // unique AST node. + return type.node; + } + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + // We track all object types that have an associated symbol (representing the origin of the type), but + // exclude the static side of classes from this check since it shares its symbol with the instance side. + return type.symbol; + } + if (isTupleType(type)) { + // Tuple types are tracked through their target type + return type.target; + } } - return t; + if (type.flags & 8388608 /* IndexedAccess */) { + // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A + do { + type = type.objectType; + } while (type.flags & 8388608 /* IndexedAccess */); + return type; + } + if (type.flags & 16777216 /* Conditional */) { + // The root object represents the origin of the conditional type + return type.root; + } + return undefined; } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; @@ -59156,8 +60738,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -59331,8 +60913,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getFalsyFlags(t); } return result; @@ -59362,7 +60944,7 @@ var ts; type.flags & 64 /* BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */) || + type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || type.flags & 128 /* StringLiteral */ && type.value === "" || type.flags & 256 /* NumberLiteral */ && type.value === 0 || type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : @@ -59665,12 +61247,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 213 /* BinaryExpression */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 216 /* BinaryExpression */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 159 /* Parameter */: + case 160 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -59685,23 +61267,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 195 /* BindingElement */: + case 198 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 304 /* JSDocFunctionType */: + case 308 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 248 /* FunctionDeclaration */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 251 /* FunctionDeclaration */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 3 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -59715,7 +61297,7 @@ var ts; wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 189 /* MappedType */: + case 190 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -59845,7 +61427,7 @@ var ts; if (objectFlags & 67108864 /* CouldContainTypeVariablesComputed */) { return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); } - var result = !!(type.flags & 63176704 /* Instantiable */ || + var result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */)) || @@ -59857,16 +61439,15 @@ var ts; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 251 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 294 /* SourceFile */ ? true : n.kind === 253 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 /* SourceFile */ ? true : n.kind === 256 /* ModuleDeclaration */ ? false : "quit"; })); } return false; } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || - type.flags & 16777216 /* Conditional */ && (isTypeParameterAtTopLevel(getTrueTypeFromConditionalType(type), typeParameter) || - isTypeParameterAtTopLevel(getFalseTypeFromConditionalType(type), typeParameter))); + type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { @@ -59913,7 +61494,8 @@ var ts; // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { return !(ts.getObjectFlags(type) & 2097152 /* NonInferrableType */) || - isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }); + isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || + isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } function createReverseMappedType(source, target, constraint) { // We consider a source type reverse mappable if it has a string index signature or if @@ -60017,17 +61599,73 @@ var ts; function isFromInferenceBlockedSource(type) { return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag)); } + function isValidBigIntString(s) { + var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var success = true; + scanner.setOnError(function () { return success = false; }); + scanner.setText(s + "n"); + var result = scanner.scan(); + if (result === 40 /* MinusToken */) { + result = scanner.scan(); + } + var flags = scanner.getTokenFlags(); + // validate that + // * scanning proceeded without error + // * a bigint can be scanned, and that when it is scanned, it is + // * the full length of the input string (so the scanner is one character beyond the augmented input length) + // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) + return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */); + } + function isStringLiteralTypeValueParsableAsType(s, target) { + if (target.flags & 1048576 /* Union */) { + return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); }); + } + switch (target) { + case stringType: return true; + case numberType: return s.value !== "" && isFinite(+(s.value)); + case bigintType: return s.value !== "" && isValidBigIntString(s.value); + // the next 4 should be handled in `getTemplateLiteralType`, as they are all exactly one value, but are here for completeness, just in case + // this function is ever used on types which don't come from template literal holes + case trueType: return s.value === "true"; + case falseType: return s.value === "false"; + case undefinedType: return s.value === "undefined"; + case nullType: return s.value === "null"; + default: return !!(target.flags & 1 /* Any */); + } + } + function inferLiteralsFromTemplateLiteralType(source, target) { + var value = source.value; + var texts = target.texts; + var lastIndex = texts.length - 1; + var startText = texts[0]; + var endText = texts[lastIndex]; + if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText))) + return undefined; + var matches = []; + var str = value.slice(startText.length, value.length - endText.length); + var pos = 0; + for (var i = 1; i < lastIndex; i++) { + var delim = texts[i]; + var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1; + if (delimPos < 0) + return undefined; + matches.push(getLiteralType(str.slice(pos, delimPos))); + pos = delimPos + delim.length; + } + matches.push(getLiteralType(str.slice(pos))); + return matches; + } function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) { if (priority === void 0) { priority = 0; } if (contravariant === void 0) { contravariant = false; } - var symbolOrTypeStack; - var visited; var bivariant = false; var propagationType; var inferencePriority = 1024 /* MaxValue */; var allowComplexConstraintInference = true; - var objectTypeComparisonDepth = 0; - var targetStack = []; + var visited; + var sourceStack; + var targetStack; + var expandingFlags = 0 /* None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -60155,7 +61793,7 @@ var ts; var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 63176704 /* Instantiable */) { + if (indexType.flags & 465829888 /* Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { invokeOnce(source, simplified_1, inferFromTypes); @@ -60184,18 +61822,13 @@ var ts; inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 16777216 /* Conditional */ && target.flags & 16777216 /* Conditional */) { - inferFromTypes(source.checkType, target.checkType); - inferFromTypes(source.extendsType, target.extendsType); - inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); - inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); + else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + if (source.symbol === target.symbol) { + inferFromTypes(source.type, target.type); + } } else if (target.flags & 16777216 /* Conditional */) { - var savePriority = priority; - priority |= contravariant ? 32 /* ContravariantConditional */ : 0; - var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; - inferToMultipleTypes(source, targetTypes, target.flags); - priority = savePriority; + invokeOnce(source, target, inferToConditionalType); } else if (target.flags & 3145728 /* UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); @@ -60208,9 +61841,12 @@ var ts; inferFromTypes(sourceType, target); } } + else if (target.flags & 134217728 /* TemplateLiteral */) { + inferToTemplateLiteralType(source, target); + } else { source = getReducedType(source); - if (!(priority & 256 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 63176704 /* Instantiable */))) { + if (!(priority & 256 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` @@ -60255,7 +61891,30 @@ var ts; (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); var saveInferencePriority = inferencePriority; inferencePriority = 1024 /* MaxValue */; - action(source, target); + // We stop inferring and report a circularity if we encounter duplicate recursion identities on both + // the source side and the target side. + var saveExpandingFlags = expandingFlags; + var sourceIdentity = getRecursionIdentity(source) || source; + var targetIdentity = getRecursionIdentity(target) || target; + if (sourceIdentity && ts.contains(sourceStack, sourceIdentity)) + expandingFlags |= 1 /* Source */; + if (targetIdentity && ts.contains(targetStack, targetIdentity)) + expandingFlags |= 2 /* Target */; + if (expandingFlags !== 3 /* Both */) { + if (sourceIdentity) + (sourceStack || (sourceStack = [])).push(sourceIdentity); + if (targetIdentity) + (targetStack || (targetStack = [])).push(targetIdentity); + action(source, target); + if (targetIdentity) + targetStack.pop(); + if (sourceIdentity) + sourceStack.pop(); + } + else { + inferencePriority = -1 /* Circularity */; + } + expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); inferencePriority = Math.min(inferencePriority, saveInferencePriority); } @@ -60312,8 +61971,8 @@ var ts; } function getSingleTypeVariableFromIntersectionTypes(types) { var typeVariable; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var type = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var type = types_15[_i]; var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; @@ -60451,40 +62110,31 @@ var ts; } return false; } - function inferFromObjectTypes(source, target) { - // If we are already processing another target type with the same associated symbol (such as - // an instantiation of the same generic type), we do not explore this target as it would yield - // no further inferences. We exclude the static side of classes from this check since it shares - // its symbol with the instance side which would lead to false positives. - var isNonConstructorObject = target.flags & 524288 /* Object */ && - !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); - var symbolOrType = ts.getObjectFlags(target) & 4 /* Reference */ && target.node ? getNormalizedType(target, /*writing*/ false) : isNonConstructorObject ? isTupleType(target) ? target.target : target.symbol : undefined; - if (symbolOrType) { - if (ts.contains(symbolOrTypeStack, symbolOrType)) { - if (ts.getObjectFlags(target) & 4 /* Reference */ && target.node) { - // Don't set the circularity flag for re-encountered recursive type references just because we're already exploring them - return; - } - inferencePriority = -1 /* Circularity */; - return; - } - targetStack[objectTypeComparisonDepth] = target; - objectTypeComparisonDepth++; - if (isDeeplyNestedType(target, targetStack, objectTypeComparisonDepth)) { - inferencePriority = -1 /* Circularity */; - objectTypeComparisonDepth--; - return; - } - (symbolOrTypeStack || (symbolOrTypeStack = [])).push(symbolOrType); - inferFromObjectTypesWorker(source, target); - symbolOrTypeStack.pop(); - objectTypeComparisonDepth--; + function inferToConditionalType(source, target) { + if (source.flags & 16777216 /* Conditional */) { + inferFromTypes(source.checkType, target.checkType); + inferFromTypes(source.extendsType, target.extendsType); + inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); + inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } else { - inferFromObjectTypesWorker(source, target); + var savePriority = priority; + priority |= contravariant ? 32 /* ContravariantConditional */ : 0; + var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; + inferToMultipleTypes(source, targetTypes, target.flags); + priority = savePriority; + } + } + function inferToTemplateLiteralType(source, target) { + var matches = source.flags & 128 /* StringLiteral */ ? inferLiteralsFromTemplateLiteralType(source, target) : + source.flags & 134217728 /* TemplateLiteral */ && ts.arraysEqual(source.texts, target.texts) ? source.types : + undefined; + var types = target.types; + for (var i = 0; i < types.length; i++) { + inferFromTypes(matches ? matches[i] : neverType, types[i]); } } - function inferFromObjectTypesWorker(source, target) { + function inferFromObjectTypes(source, target) { if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); @@ -60495,8 +62145,12 @@ var ts; // from S to T and from X to Y. inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + var sourceNameType = getNameTypeFromMappedType(source); + var targetNameType = getNameTypeFromMappedType(target); + if (sourceNameType && targetNameType) + inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */) { + if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -60604,7 +62258,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 164 /* MethodDeclaration */ || kind === 163 /* MethodSignature */ || kind === 165 /* Constructor */; + bivariant = bivariant || kind === 165 /* MethodDeclaration */ || kind === 164 /* MethodSignature */ || kind === 166 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -60639,7 +62293,7 @@ var ts; } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); @@ -60748,22 +62402,22 @@ var ts; return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom; case "$": return compilerOptions.types - ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig - : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery; + ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig + : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery; case "describe": case "suite": case "it": case "test": return compilerOptions.types - ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig - : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha; + ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig + : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha; case "process": case "require": case "Buffer": case "module": return compilerOptions.types - ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig - : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode; + ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig + : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode; case "Map": case "Set": case "Promise": @@ -60772,9 +62426,19 @@ var ts; case "WeakSet": case "Iterator": case "AsyncIterator": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; + case "SharedArrayBuffer": + case "Atomics": + case "AsyncIterable": + case "AsyncIterableIterator": + case "AsyncGenerator": + case "AsyncGeneratorFunction": + case "BigInt": + case "Reflect": + case "BigInt64Array": + case "BigUint64Array": + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later; default: - if (node.parent.kind === 286 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 289 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -60795,7 +62459,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 175 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 156 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 176 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 157 /* QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -60810,11 +62474,11 @@ var ts; return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; case 107 /* ThisKeyword */: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 222 /* NonNullExpression */: - case 204 /* ParenthesizedExpression */: + case 225 /* NonNullExpression */: + case 207 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -60825,26 +62489,28 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 204 /* ParenthesizedExpression */: - case 222 /* NonNullExpression */: + case 207 /* ParenthesizedExpression */: + case 225 /* NonNullExpression */: return isMatchingReference(source, target.expression); - case 213 /* BinaryExpression */: - return ts.isAssignmentExpression(target) && isMatchingReference(source, target.left); + case 216 /* BinaryExpression */: + return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { case 78 /* Identifier */: + case 79 /* PrivateIdentifier */: return target.kind === 78 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 246 /* VariableDeclaration */ || target.kind === 195 /* BindingElement */) && + (target.kind === 249 /* VariableDeclaration */ || target.kind === 198 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 107 /* ThisKeyword */: return target.kind === 107 /* ThisKeyword */; case 105 /* SuperKeyword */: return target.kind === 105 /* SuperKeyword */; - case 222 /* NonNullExpression */: - case 204 /* ParenthesizedExpression */: + case 225 /* NonNullExpression */: + case 207 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -60854,11 +62520,11 @@ var ts; // Given a source x, check if target matches x or is an && operation with an operand that matches x. function containsTruthyCheck(source, target) { return isMatchingReference(source, target) || - (target.kind === 213 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && + (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); } function getAccessedPropertyName(access) { - return access.kind === 198 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 201 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -60887,7 +62553,7 @@ var ts; if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && - !maybeTypeOfKind(getTypeOfSymbol(prop), 63176704 /* Instantiable */); + !maybeTypeOfKind(getTypeOfSymbol(prop), 465829888 /* Instantiable */); } return !!prop.isDiscriminantProperty; } @@ -60920,7 +62586,7 @@ var ts; } } } - if (callExpression.expression.kind === 198 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 201 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -60969,8 +62635,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; result |= getTypeFacts(t); } return result; @@ -61041,7 +62707,7 @@ var ts; if (flags & 131072 /* Never */) { return 0 /* None */; } - if (flags & 63176704 /* Instantiable */) { + if (flags & 465829888 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || unknownType); } if (flags & 3145728 /* UnionOrIntersection */) { @@ -61065,28 +62731,35 @@ var ts; return errorType; var text = getPropertyNameFromType(nameType); return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || - isNumericLiteralName(text) && getIndexTypeOfType(type, 1 /* Number */) || - getIndexTypeOfType(type, 0 /* String */) || + isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1 /* Number */)) || + includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0 /* String */)) || errorType; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } + function includeUndefinedInIndexSignature(type) { + if (!type) + return type; + return compilerOptions.noUncheckedIndexedAccess ? + getUnionType([type, undefinedType]) : + type; + } function getTypeOfDestructuredSpreadExpression(type) { return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 196 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 285 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 199 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 288 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 213 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 236 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 216 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 239 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -61103,21 +62776,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return stringType; - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 207 /* DeleteExpression */: + case 210 /* DeleteExpression */: return undefinedType; - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 217 /* SpreadElement */: + case 220 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -61125,7 +62798,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 193 /* ObjectBindingPattern */ ? + var type = pattern.kind === 196 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -61143,30 +62816,30 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 235 /* ForInStatement */) { + if (node.parent.parent.kind === 238 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 236 /* ForOfStatement */) { + if (node.parent.parent.kind === 239 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 246 /* VariableDeclaration */ ? + return node.kind === 249 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 246 /* VariableDeclaration */ && node.initializer && + return node.kind === 249 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 195 /* BindingElement */ && node.parent.kind === 213 /* BinaryExpression */ && + node.kind !== 198 /* BindingElement */ && node.parent.kind === 216 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: switch (node.operatorToken.kind) { case 62 /* EqualsToken */: case 74 /* BarBarEqualsToken */: @@ -61181,13 +62854,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 204 /* ParenthesizedExpression */ || - parent.kind === 213 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || - parent.kind === 213 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 207 /* ParenthesizedExpression */ || + parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 281 /* CaseClause */) { + if (clause.kind === 284 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -61207,7 +62880,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 281 /* CaseClause */) { + if (clause.kind === 284 /* CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -61344,8 +63017,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -61369,12 +63042,12 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 200 /* CallExpression */ + parent.parent.kind === 203 /* CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 199 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 202 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 213 /* BinaryExpression */ && + parent.parent.kind === 216 /* BinaryExpression */ && parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -61382,8 +63055,8 @@ var ts; return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return (declaration.kind === 246 /* VariableDeclaration */ || declaration.kind === 159 /* Parameter */ || - declaration.kind === 162 /* PropertyDeclaration */ || declaration.kind === 161 /* PropertySignature */) && + return (declaration.kind === 249 /* VariableDeclaration */ || declaration.kind === 160 /* Parameter */ || + declaration.kind === 163 /* PropertyDeclaration */ || declaration.kind === 162 /* PropertySignature */) && !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { @@ -61391,12 +63064,18 @@ var ts; return getTypeOfSymbol(symbol); } if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + var origin = symbol.syntheticOrigin; + if (origin && getExplicitTypeOfSymbol(origin)) { + return getTypeOfSymbol(symbol); + } + } var declaration = symbol.valueDeclaration; if (declaration) { if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 236 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { @@ -61424,11 +63103,11 @@ var ts; return getExplicitThisType(node); case 105 /* SuperKeyword */: return checkSuperExpression(node); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: var type = getTypeOfDottedName(node.expression, diagnostic); var prop = type && getPropertyOfType(type, node.name.escapedText); return prop && getExplicitTypeOfSymbol(prop, diagnostic); - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -61442,7 +63121,7 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 230 /* ExpressionStatement */) { + if (node.parent.kind === 233 /* ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } else if (node.expression.kind !== 105 /* SuperKeyword */) { @@ -61486,7 +63165,7 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); - return node.kind === 94 /* FalseKeyword */ || node.kind === 213 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + return node.kind === 94 /* FalseKeyword */ || node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { @@ -61605,7 +63284,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 536624127 /* Narrowable */)) { return declaredType; } flowInvocationCount++; @@ -61617,7 +63296,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 222 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 225 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -61632,6 +63311,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. + ts.tracing.instant("check" /* Check */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -61698,8 +63378,8 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 198 /* PropertyAccessExpression */ && - reference.kind !== 199 /* ElementAccessExpression */ && + reference.kind !== 201 /* PropertyAccessExpression */ && + reference.kind !== 202 /* ElementAccessExpression */ && reference.kind !== 107 /* ThisKeyword */) { flow = container.flowNode; continue; @@ -61724,7 +63404,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getConstraintForLocation(node.kind === 246 /* VariableDeclaration */ || node.kind === 195 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -61764,14 +63444,14 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 205 /* FunctionExpression */ || init.kind === 206 /* ArrowFunction */)) { + if (init && (init.kind === 208 /* FunctionExpression */ || init.kind === 209 /* ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 235 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 238 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -61782,7 +63462,7 @@ var ts; if (node.kind === 94 /* FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 213 /* BinaryExpression */) { + if (node.kind === 216 /* BinaryExpression */) { if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -61813,7 +63493,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 200 /* CallExpression */ ? + var expr = node.kind === 203 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -61821,7 +63501,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 200 /* CallExpression */) { + if (node.kind === 203 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -61869,7 +63549,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 208 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 211 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -61877,7 +63557,7 @@ var ts; if (optionalChainContainsReference(expr, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); } - else if (expr.kind === 208 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 211 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); } } @@ -62095,10 +63775,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 208 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 208 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -62218,7 +63898,7 @@ var ts; if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { // The pattern x && typeof x === 'object', where x is of type unknown, narrows x to type object. We don't // need to check for the reverse typeof x === 'object' && x since that already narrows correctly. - if (typeOfExpr.parent.parent.kind === 213 /* BinaryExpression */) { + if (typeOfExpr.parent.parent.kind === 216 /* BinaryExpression */) { var expr = typeOfExpr.parent.parent; if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { return nonPrimitiveType; @@ -62301,7 +63981,7 @@ var ts; if (isTypeSubtypeOf(candidate, type)) { return candidate; } - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & 465829888 /* Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(candidate, constraint)) { return getIntersectionType([type, candidate]); @@ -62466,15 +64146,10 @@ var ts; return assignableType; } } - // If the candidate type is a subtype of the target type, narrow to the candidate type. - // Otherwise, if the target type is assignable to the candidate type, keep the target type. - // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate - // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the - // two types. - return isTypeSubtypeOf(candidate, type) ? candidate : - isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, type) ? candidate : - getIntersectionType([type, candidate]); + // If the candidate type is a subtype of the target type, narrow to the candidate type, + // if the target type is a subtype of the candidate type, narrow to the target type, + // otherwise, narrow to an intersection of the two types. + return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, candidate]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { @@ -62517,16 +64192,17 @@ var ts; case 78 /* Identifier */: case 107 /* ThisKeyword */: case 105 /* SuperKeyword */: - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: + case 225 /* NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -62571,9 +64247,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 254 /* ModuleBlock */ || - node.kind === 294 /* SourceFile */ || - node.kind === 162 /* PropertyDeclaration */; + node.kind === 257 /* ModuleBlock */ || + node.kind === 297 /* SourceFile */ || + node.kind === 163 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -62595,7 +64271,7 @@ var ts; if (node.kind === 78 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 159 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160 /* Parameter */) { symbol.isAssigned = true; } } @@ -62611,7 +64287,7 @@ var ts; function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 159 /* Parameter */ && + declaration.kind === 160 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -62625,10 +64301,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 198 /* PropertyAccessExpression */ || - parent.kind === 200 /* CallExpression */ && parent.expression === node || - parent.kind === 199 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 195 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 201 /* PropertyAccessExpression */ || + parent.kind === 203 /* CallExpression */ && parent.expression === node || + parent.kind === 202 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 198 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -62670,7 +64346,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 206 /* ArrowFunction */) { + if (container.kind === 209 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { @@ -62686,16 +64362,16 @@ var ts; markAliasReferenced(symbol, node); } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && ts.getCombinedNodeFlags(declaration) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node.parent, localOrExportSymbol)) { + var sourceSymbol = localOrExportSymbol.flags & 2097152 /* Alias */ ? resolveAlias(localOrExportSymbol) : localOrExportSymbol; + if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node.parent, sourceSymbol)) { errorOrSuggestion(/* isError */ false, node, ts.Diagnostics._0_is_deprecated, node.escapedText); - ; } + var declaration = localOrExportSymbol.valueDeclaration; if (localOrExportSymbol.flags & 32 /* Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 249 /* ClassDeclaration */ + if (declaration.kind === 252 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -62707,14 +64383,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 218 /* ClassExpression */) { + else if (declaration.kind === 221 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 294 /* SourceFile */) { + while (container.kind !== 297 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 162 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { + if (container.kind === 163 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -62763,7 +64439,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 159 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 160 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -62772,8 +64448,8 @@ var ts; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 205 /* FunctionExpression */ || - flowContainer.kind === 206 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 208 /* FunctionExpression */ || + flowContainer.kind === 209 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -62782,9 +64458,9 @@ var ts; // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 267 /* ExportSpecifier */) || - node.parent.kind === 222 /* NonNullExpression */ || - declaration.kind === 246 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 270 /* ExportSpecifier */) || + node.parent.kind === 225 /* NonNullExpression */ || + declaration.kind === 249 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -62819,7 +64495,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 284 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 287 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -62842,7 +64518,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 247 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -62863,7 +64539,7 @@ var ts; // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 247 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -62882,7 +64558,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 204 /* ParenthesizedExpression */) { + while (current.parent.kind === 207 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -62890,7 +64566,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 211 /* PrefixUnaryExpression */ || current.parent.kind === 212 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 214 /* PrefixUnaryExpression */ || current.parent.kind === 215 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } @@ -62903,7 +64579,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 162 /* PropertyDeclaration */ || container.kind === 165 /* Constructor */) { + if (container.kind === 163 /* PropertyDeclaration */ || container.kind === 166 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -62943,37 +64619,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 165 /* Constructor */) { + if (container.kind === 166 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 206 /* ArrowFunction */) { + if (container.kind === 209 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 165 /* Constructor */: + case 166 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -63061,7 +64737,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 205 /* FunctionExpression */ && + if (container.kind === 208 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -63071,16 +64747,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 164 /* MethodDeclaration */ && - container.parent.kind === 197 /* ObjectLiteralExpression */ && + else if (container.kind === 165 /* MethodDeclaration */ && + container.parent.kind === 200 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 205 /* FunctionExpression */ && - container.parent.kind === 285 /* PropertyAssignment */ && - container.parent.parent.kind === 197 /* ObjectLiteralExpression */ && + else if (container.kind === 208 /* FunctionExpression */ && + container.parent.kind === 288 /* PropertyAssignment */ && + container.parent.parent.kind === 200 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -63088,7 +64764,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 205 /* FunctionExpression */ && + else if (container.kind === 208 /* FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -63113,7 +64789,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 304 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 308 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -63127,16 +64803,16 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 159 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 200 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 203 /* CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 206 /* ArrowFunction */) { + while (container && container.kind === 209 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -63149,14 +64825,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 157 /* ComputedPropertyName */; }); - if (current && current.kind === 157 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158 /* ComputedPropertyName */; }); + if (current && current.kind === 158 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 197 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 200 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -63164,7 +64840,7 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 165 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 166 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasSyntacticModifier(container, 32 /* Static */) || isCallExpression) { @@ -63233,7 +64909,7 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 164 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 165 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -63247,7 +64923,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 197 /* ObjectLiteralExpression */) { + if (container.parent.kind === 200 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -63268,7 +64944,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 165 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 166 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; @@ -63283,7 +64959,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 165 /* Constructor */; + return container.kind === 166 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -63291,21 +64967,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 197 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 200 /* ObjectLiteralExpression */) { if (ts.hasSyntacticModifier(container, 32 /* Static */)) { - return container.kind === 164 /* MethodDeclaration */ || - container.kind === 163 /* MethodSignature */ || - container.kind === 166 /* GetAccessor */ || - container.kind === 167 /* SetAccessor */; + return container.kind === 165 /* MethodDeclaration */ || + container.kind === 164 /* MethodSignature */ || + container.kind === 167 /* GetAccessor */ || + container.kind === 168 /* SetAccessor */; } else { - return container.kind === 164 /* MethodDeclaration */ || - container.kind === 163 /* MethodSignature */ || - container.kind === 166 /* GetAccessor */ || - container.kind === 167 /* SetAccessor */ || - container.kind === 162 /* PropertyDeclaration */ || - container.kind === 161 /* PropertySignature */ || - container.kind === 165 /* Constructor */; + return container.kind === 165 /* MethodDeclaration */ || + container.kind === 164 /* MethodSignature */ || + container.kind === 167 /* GetAccessor */ || + container.kind === 168 /* SetAccessor */ || + container.kind === 163 /* PropertyDeclaration */ || + container.kind === 162 /* PropertySignature */ || + container.kind === 166 /* Constructor */; } } } @@ -63313,10 +64989,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 164 /* MethodDeclaration */ || - func.kind === 166 /* GetAccessor */ || - func.kind === 167 /* SetAccessor */) && func.parent.kind === 197 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 205 /* FunctionExpression */ && func.parent.kind === 285 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 165 /* MethodDeclaration */ || + func.kind === 167 /* GetAccessor */ || + func.kind === 168 /* SetAccessor */) && func.parent.kind === 200 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 208 /* FunctionExpression */ && func.parent.kind === 288 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -63328,7 +65004,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 206 /* ArrowFunction */) { + if (func.kind === 209 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -63355,7 +65031,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 285 /* PropertyAssignment */) { + if (literal.parent.kind !== 288 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -63369,7 +65045,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 213 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -63422,26 +65098,42 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 159 /* Parameter */: + case 160 /* Parameter */: return getContextuallyTypedParameterType(declaration); - case 195 /* BindingElement */: + case 198 /* BindingElement */: return getContextualTypeForBindingElement(declaration); - // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent + case 163 /* PropertyDeclaration */: + if (ts.hasSyntacticModifier(declaration, 32 /* Static */)) { + return getContextualTypeForStaticPropertyDeclaration(declaration); + } + // By default, do nothing and return undefined - only the above cases have context implied by a parent } } function getContextualTypeForBindingElement(declaration) { var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 195 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); - if (parentType && !ts.isBindingPattern(name) && !ts.isComputedNonLiteralName(name)) { - var nameType = getLiteralTypeFromPropertyName(name); - if (isTypeUsableAsPropertyName(nameType)) { - var text = getPropertyNameFromType(nameType); - return getTypeOfPropertyOfType(parentType, text); - } + parent.kind !== 198 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); + if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) + return undefined; + if (parent.name.kind === 197 /* ArrayBindingPattern */) { + var index = ts.indexOfNode(declaration.parent.elements, declaration); + if (index < 0) + return undefined; + return getContextualTypeForElementExpression(parentType, index); + } + var nameType = getLiteralTypeFromPropertyName(name); + if (isTypeUsableAsPropertyName(nameType)) { + var text = getPropertyNameFromType(nameType); + return getTypeOfPropertyOfType(parentType, text); } } + function getContextualTypeForStaticPropertyDeclaration(declaration) { + var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent); + if (!parentType) + return undefined; + return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName); + } // In a variable, parameter or property declaration with a type annotation, // the contextual type of an initializer expression is the type of the variable, parameter or property. // Otherwise, in a parameter declaration of a contextually typed function expression, @@ -63561,7 +65253,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 202 /* TaggedTemplateExpression */) { + if (template.parent.kind === 205 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -63574,14 +65266,7 @@ var ts; case 75 /* AmpersandAmpersandEqualsToken */: case 74 /* BarBarEqualsToken */: case 76 /* QuestionQuestionEqualsToken */: - if (node !== right) { - return undefined; - } - var contextSensitive = getIsContextSensitiveAssignmentOrContextType(binaryExpression); - if (!contextSensitive) { - return undefined; - } - return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; + return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except @@ -63601,24 +65286,27 @@ var ts; } // In an assignment expression, the right operand is contextually typed by the type of the left operand. // Don't do this for assignment declarations unless there is a type tag on the assignment, to avoid circularity from checking the right operand. - function getIsContextSensitiveAssignmentOrContextType(binaryExpression) { + function getContextualTypeForAssignmentDeclaration(binaryExpression) { var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { case 0 /* None */: - return true; + return getTypeOfExpression(binaryExpression.left); case 5 /* Property */: case 1 /* ExportsProperty */: case 6 /* Prototype */: case 3 /* PrototypeProperty */: + if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { + return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + } // If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration. // See `bindStaticPropertyAssignment` in `binder.ts`. - if (!binaryExpression.left.symbol) { - return true; + else if (!binaryExpression.left.symbol) { + return getTypeOfExpression(binaryExpression.left); } else { var decl = binaryExpression.left.symbol.valueDeclaration; if (!decl) { - return false; + return undefined; } var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); @@ -63631,39 +65319,19 @@ var ts; if (parentSymbol) { var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); - if (nameStr_1 !== undefined) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); - return type || false; + var nameStr = ts.getElementOrPropertyAccessName(lhs); + if (nameStr !== undefined) { + return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr); } } - return false; + return undefined; } } - return !ts.isInJSFile(decl); + return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left); } case 2 /* ModuleExports */: case 4 /* ThisProperty */: - if (!binaryExpression.symbol) - return true; - if (binaryExpression.symbol.valueDeclaration) { - var annotated = ts.getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration); - if (annotated) { - var type = getTypeFromTypeNode(annotated); - if (type) { - return type; - } - } - } - if (kind === 2 /* ModuleExports */) - return false; - var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); - if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { - return false; - } - var thisType = checkThisExpression(thisAccess.expression); - var nameStr = ts.getElementOrPropertyAccessName(thisAccess); - return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; + return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -63672,6 +65340,40 @@ var ts; return ts.Debug.assertNever(kind); } } + function isPossiblyAliasedThisProperty(declaration, kind) { + if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } + if (kind === 4 /* ThisProperty */) { + return true; + } + if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + return false; + } + var name = declaration.left.expression.escapedText; + var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); + } + function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) { + if (!binaryExpression.symbol) + return getTypeOfExpression(binaryExpression.left); + if (binaryExpression.symbol.valueDeclaration) { + var annotated = ts.getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration); + if (annotated) { + var type = getTypeFromTypeNode(annotated); + if (type) { + return type; + } + } + } + if (kind === 2 /* ModuleExports */) + return undefined; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); + if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { + return undefined; + } + var thisType = checkThisExpression(thisAccess.expression); + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; + } function isCircularMappedProperty(symbol) { return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); } @@ -63741,7 +65443,8 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || getIteratedTypeOrElementType(1 /* Element */, arrayContextualType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false)); + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. function getContextualTypeForConditionalOperand(node, contextFlags) { @@ -63755,7 +65458,7 @@ var ts; if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { return undefined; } - var realChildren = getSemanticJsxChildren(node.children); + var realChildren = ts.getSemanticJsxChildren(node.children); var childIndex = realChildren.indexOf(child); var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName); return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) { @@ -63803,21 +65506,21 @@ var ts; case 94 /* FalseKeyword */: case 103 /* NullKeyword */: case 78 /* Identifier */: - case 149 /* UndefinedKeyword */: + case 150 /* UndefinedKeyword */: return true; - case 198 /* PropertyAccessExpression */: - case 204 /* ParenthesizedExpression */: + case 201 /* PropertyAccessExpression */: + case 207 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 280 /* JsxExpression */: + case 283 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 288 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 277 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 280 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -63842,7 +65545,7 @@ var ts; // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 63176704 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. @@ -63865,7 +65568,7 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & 465829888 /* Instantiable */) { return instantiateType(type, mapper); } if (type.flags & 1048576 /* Union */) { @@ -63903,58 +65606,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 246 /* VariableDeclaration */: - case 159 /* Parameter */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 195 /* BindingElement */: + case 249 /* VariableDeclaration */: + case 160 /* Parameter */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 198 /* BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 206 /* ArrowFunction */: - case 239 /* ReturnStatement */: + case 209 /* ArrowFunction */: + case 242 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 210 /* AwaitExpression */: + case 213 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 200 /* CallExpression */: + case 203 /* CallExpression */: if (parent.expression.kind === 99 /* ImportKeyword */) { return stringType; } /* falls through */ - case 201 /* NewExpression */: + case 204 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 203 /* TypeAssertionExpression */: - case 221 /* AsExpression */: + case 206 /* TypeAssertionExpression */: + case 224 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 285 /* PropertyAssignment */: - case 286 /* ShorthandPropertyAssignment */: + case 288 /* PropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 287 /* SpreadAssignment */: + case 290 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 196 /* ArrayLiteralExpression */: { + case 199 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 225 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 215 /* TemplateExpression */); + case 228 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 218 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 204 /* ParenthesizedExpression */: { + case 207 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 280 /* JsxExpression */: + case 283 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 277 /* JsxAttribute */: - case 279 /* JsxSpreadAttribute */: + case 280 /* JsxAttribute */: + case 282 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 272 /* JsxOpeningElement */: - case 271 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: + case 274 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -64117,7 +65820,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 205 /* FunctionExpression */ || node.kind === 206 /* ArrowFunction */; + return node.kind === 208 /* FunctionExpression */ || node.kind === 209 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -64131,7 +65834,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 164 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -64145,8 +65848,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var current = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var current = types_18[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -64179,8 +65882,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 195 /* BindingElement */ && !!node.initializer) || - (node.kind === 213 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); + return (node.kind === 198 /* BindingElement */ && !!node.initializer) || + (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -64192,7 +65895,7 @@ var ts; var inConstContext = isConstContext(node); for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 217 /* SpreadElement */) { + if (e.kind === 220 /* SpreadElement */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 2048 /* SpreadArrays */); } @@ -64255,7 +65958,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: return isNumericComputedName(name); case 78 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -64305,7 +66008,7 @@ var ts; // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -64351,7 +66054,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 193 /* ObjectBindingPattern */ || contextualType.pattern.kind === 197 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 196 /* ObjectBindingPattern */ || contextualType.pattern.kind === 200 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -64374,16 +66077,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 157 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 158 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 285 /* PropertyAssignment */ || - memberDecl.kind === 286 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 288 /* PropertyAssignment */ || + memberDecl.kind === 289 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 285 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 288 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 286 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 289 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -64406,8 +66109,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 285 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 286 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 288 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 289 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -64433,7 +66136,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 287 /* SpreadAssignment */) { + else if (memberDecl.kind === 290 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -64462,7 +66165,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 166 /* GetAccessor */ || memberDecl.kind === 167 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 167 /* GetAccessor */ || memberDecl.kind === 168 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -64487,7 +66190,7 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 287 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 290 /* SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { @@ -64529,7 +66232,7 @@ var ts; } } function isValidSpreadType(type) { - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & 465829888 /* Instantiable */) { var constraint = getBaseConstraintOfType(type); if (constraint !== undefined) { return isValidSpreadType(constraint); @@ -64541,7 +66244,6 @@ var ts; } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); - resolveUntypedCall(node); // ensure type arguments and parameters are typechecked, even if there is an arity error } function checkJsxSelfClosingElement(node, _checkMode) { checkNodeDeferred(node); @@ -64568,7 +66270,7 @@ var ts; // by default, jsx:'react' will use jsxFactory = React.createElement and jsxFragmentFactory = React.Fragment // if jsxFactory compiler option is provided, ensure jsxFragmentFactory compiler option or @jsxFrag pragma is provided too var nodeSourceFile = ts.getSourceFileOfNode(node); - if (compilerOptions.jsx === 2 /* React */ && (compilerOptions.jsxFactory || nodeSourceFile.pragmas.has("jsx")) + if (ts.getJSXTransformEnabled(compilerOptions) && (compilerOptions.jsxFactory || nodeSourceFile.pragmas.has("jsx")) && !compilerOptions.jsxFragmentFactory && !nodeSourceFile.pragmas.has("jsxfrag")) { error(node, compilerOptions.jsxFactory ? ts.Diagnostics.The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_compiler_option @@ -64620,7 +66322,7 @@ var ts; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); objectFlags |= ts.getObjectFlags(exprType) & 3670016 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | 33554432 /* Transient */ | member.flags, member.escapedName); + var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -64635,7 +66337,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 279 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 282 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -64661,7 +66363,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 270 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 273 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -64675,7 +66377,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */ | 33554432 /* Transient */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -64718,6 +66420,9 @@ var ts; childrenTypes.push(stringType); } } + else if (child.kind === 283 /* JsxExpression */ && !child.expression) { + continue; // empty jsx expressions don't *really* count as present children + } else { childrenTypes.push(checkExpressionForMutableLocation(child, checkMode)); } @@ -64787,29 +66492,60 @@ var ts; } return links.resolvedSymbol; } + function getJsxNamespaceContainerForImplicitImport(location) { + var file = location && ts.getSourceFileOfNode(location); + var links = file && getNodeLinks(file); + if (links && links.jsxImplicitImportContainer === false) { + return undefined; + } + if (links && links.jsxImplicitImportContainer) { + return links.jsxImplicitImportContainer; + } + var runtimeImportSpecifier = ts.getJSXRuntimeImport(ts.getJSXImplicitImportBase(compilerOptions, file), compilerOptions); + if (!runtimeImportSpecifier) { + return undefined; + } + var isClassic = ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Classic; + var errorMessage = isClassic + ? ts.Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option + : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations; + var mod = resolveExternalModule(location, runtimeImportSpecifier, errorMessage, location); + var result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : undefined; + if (links) { + links.jsxImplicitImportContainer = result || false; + } + return result; + } function getJsxNamespaceAt(location) { var links = location && getNodeLinks(location); if (links && links.jsxNamespace) { return links.jsxNamespace; } if (!links || links.jsxNamespace !== false) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); + if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { + var namespaceName = getJsxNamespace(location); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + } if (resolvedNamespace) { var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); - if (candidate) { + if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; } return candidate; } - if (links) { - links.jsxNamespace = false; - } + } + if (links) { + links.jsxNamespace = false; } } // JSX global fallback - return getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); // TODO: GH#18217 + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + if (s === unknownSymbol) { + return undefined; // TODO: GH#18217 + } + return s; // TODO: GH#18217 } /** * Look into JSX namespace and then look for container with matching name as nameOfAttribPropContainer. @@ -64996,23 +66732,25 @@ var ts; checkGrammarJsxElement(node); } checkJsxPreconditions(node); - // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. - // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; - var jsxFactoryNamespace = getJsxNamespace(node); - var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; - // allow null as jsxFragmentFactory - var jsxFactorySym; - if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); - } - if (jsxFactorySym) { - // Mark local symbol as referenced here because it might not have been marked - // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; - // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { - markAliasSymbolAsReferenced(jsxFactorySym); + if (!getJsxNamespaceContainerForImplicitImport(node)) { + // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. + // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryNamespace = getJsxNamespace(node); + var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; + // allow null as jsxFragmentFactory + var jsxFactorySym = void 0; + if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + } + if (jsxFactorySym) { + // Mark local symbol as referenced here because it might not have been marked + // if jsx emit was not jsxFactory as there wont be error being emitted + jsxFactorySym.isReferenced = 67108863 /* All */; + // If react/jsxFactory symbol is alias, mark it as refereced + if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + markAliasSymbolAsReferenced(jsxFactorySym); + } } } if (isNodeOpeningLikeElement) { @@ -65102,7 +66840,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 156 /* QualifiedName */ ? node.right : node.kind === 192 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 157 /* QualifiedName */ ? node.right : node.kind === 195 /* ImportType */ ? node : node.name; if (isSuper) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -65256,7 +66994,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 204 /* ParenthesizedExpression */) { + while (node.parent.kind === 207 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -65314,10 +67052,10 @@ var ts; return false; } function isThisPropertyAccessInConstructor(node, prop) { - return ts.isThisProperty(node) && (isAutoTypedProperty(prop) || isConstructorDeclaredProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); + return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop)) + && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); } function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { - var _a; var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -65379,10 +67117,10 @@ var ts; if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); } - propType = indexInfo.type; + propType = (compilerOptions.noUncheckedIndexedAccess && !ts.isAssignmentTarget(node)) ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } else { - if (((_a = prop.valueDeclaration) === null || _a === void 0 ? void 0 : _a.flags) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { + if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { errorOrSuggestion(/* isError */ false, right, ts.Diagnostics._0_is_deprecated, right.escapedText); } checkPropertyNotUsedBeforeDeclaration(prop, node, right); @@ -65419,7 +67157,7 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 165 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { + if (flowContainer.kind === 166 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { assumeUninitialized = true; } } @@ -65451,8 +67189,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 249 /* ClassDeclaration */ && - node.parent.kind !== 172 /* TypeReference */ && + else if (valueDeclaration.kind === 252 /* ClassDeclaration */ && + node.parent.kind !== 173 /* TypeReference */ && !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -65464,22 +67202,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return true; - case 285 /* PropertyAssignment */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 287 /* SpreadAssignment */: - case 157 /* ComputedPropertyName */: - case 225 /* TemplateSpan */: - case 280 /* JsxExpression */: - case 277 /* JsxAttribute */: - case 278 /* JsxAttributes */: - case 279 /* JsxSpreadAttribute */: - case 272 /* JsxOpeningElement */: - case 220 /* ExpressionWithTypeArguments */: - case 283 /* HeritageClause */: + case 288 /* PropertyAssignment */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 290 /* SpreadAssignment */: + case 158 /* ComputedPropertyName */: + case 228 /* TemplateSpan */: + case 283 /* JsxExpression */: + case 280 /* JsxAttribute */: + case 281 /* JsxAttributes */: + case 282 /* JsxSpreadAttribute */: + case 275 /* JsxOpeningElement */: + case 223 /* ExpressionWithTypeArguments */: + case 286 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -65535,14 +67273,22 @@ var ts; relatedInfo = ts.createDiagnosticForNode(propNode, ts.Diagnostics.Did_you_forget_to_use_await); } else { - var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType); - if (suggestion !== undefined) { - var suggestedName = ts.symbolName(suggestion); - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestedName); - relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); + var missingProperty = ts.declarationNameToString(propNode); + var container = typeToString(containingType); + var libSuggestion = getSuggestedLibForNonExistentProperty(missingProperty, containingType); + if (libSuggestion !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later, missingProperty, container, libSuggestion); } else { - errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType); + if (suggestion !== undefined) { + var suggestedName = ts.symbolName(suggestion); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, missingProperty, container, suggestedName); + relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); + } + else { + errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container); + } } } } @@ -65556,6 +67302,34 @@ var ts; var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName); return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); } + function getSuggestedLibForNonExistentName(name) { + var missingName = diagnosticName(name); + var allFeatures = ts.getScriptTargetFeatures(); + var libTargets = ts.getOwnKeys(allFeatures); + for (var _i = 0, libTargets_1 = libTargets; _i < libTargets_1.length; _i++) { + var libTarget = libTargets_1[_i]; + var containingTypes = ts.getOwnKeys(allFeatures[libTarget]); + if (containingTypes !== undefined && ts.contains(containingTypes, missingName)) { + return libTarget; + } + } + } + function getSuggestedLibForNonExistentProperty(missingProperty, containingType) { + var container = getApparentType(containingType).symbol; + if (!container) { + return undefined; + } + var allFeatures = ts.getScriptTargetFeatures(); + var libTargets = ts.getOwnKeys(allFeatures); + for (var _i = 0, libTargets_2 = libTargets; _i < libTargets_2.length; _i++) { + var libTarget = libTargets_2[_i]; + var featuresOfLib = allFeatures[libTarget]; + var featuresOfContainingType = featuresOfLib[ts.symbolName(container)]; + if (featuresOfContainingType !== undefined && ts.contains(featuresOfContainingType, missingProperty)) { + return libTarget; + } + } + } function getSuggestedSymbolForNonexistentProperty(name, containingType) { return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } @@ -65676,16 +67450,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression.kind === 105 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 192 /* ImportType */: + case 195 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 198 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 201 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -65708,7 +67482,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 247 /* VariableDeclarationList */) { + if (initializer.kind === 250 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -65737,7 +67511,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 235 /* ForInStatement */ && + if (node.kind === 238 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -65774,7 +67548,7 @@ var ts; var accessFlags = ts.isAssignmentTarget(node) ? 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; - var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType; + var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { @@ -65821,13 +67595,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 202 /* TaggedTemplateExpression */) { + if (node.kind === 205 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 160 /* Decorator */) { + else if (node.kind !== 161 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -65891,7 +67665,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 217 /* SpreadElement */ || arg.kind === 224 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 220 /* SpreadElement */ || arg.kind === 227 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -65899,15 +67673,18 @@ var ts; function acceptsVoid(t) { return !!(t.flags & 16384 /* Void */); } + function acceptsVoidUndefinedUnknownOrAny(t) { + return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } var argCount; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 202 /* TaggedTemplateExpression */) { + if (node.kind === 205 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 215 /* TemplateExpression */) { + if (node.template.kind === 218 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -65922,7 +67699,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 160 /* Decorator */) { + else if (node.kind === 161 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -65936,7 +67713,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 201 /* NewExpression */); + ts.Debug.assert(node.kind === 204 /* NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -65960,7 +67737,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { return false; } } @@ -66030,7 +67807,7 @@ var ts; // example, given a 'function wrap<T, U>(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 160 /* Decorator */) { + if (node.kind !== 161 /* Decorator */) { var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -66079,7 +67856,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 219 /* OmittedExpression */) { + if (arg.kind !== 222 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -66103,7 +67880,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 224 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 227 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -66113,24 +67890,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 224 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 227 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); flags.push(8 /* Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 217 /* SpreadElement */ ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 220 /* SpreadElement */ ? arg.expression : arg)); flags.push(4 /* Rest */); } } else { var contextualType = getIndexedAccessType(restType, getLiteralType(i - index)); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1 /* Required */); } - if (arg.kind === 224 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 227 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -66271,7 +68048,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 201 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 204 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -66301,7 +68078,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 219 /* OmittedExpression */) { + if (arg.kind !== 222 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -66342,7 +68119,7 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 200 /* CallExpression */) { + if (node.kind === 203 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); if (ts.isAccessExpression(callee)) { return callee.expression; @@ -66359,17 +68136,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 202 /* TaggedTemplateExpression */) { + if (node.kind === 205 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 215 /* TemplateExpression */) { + if (template.kind === 218 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 160 /* Decorator */) { + if (node.kind === 161 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -66380,10 +68157,10 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_19 = function (i) { + var _loop_20 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 217 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 220 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -66397,7 +68174,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_19(i); + _loop_20(i); } return effectiveArgs_1; } @@ -66410,30 +68187,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 159 /* Parameter */: + case 160 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 165 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 166 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 162 /* PropertyDeclaration */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 163 /* PropertyDeclaration */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 162 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 163 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -66447,17 +68224,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: return 1; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return 2; - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 159 /* Parameter */: + case 160 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -66488,6 +68265,20 @@ var ts; return ts.createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3); } } + function isPromiseResolveArityError(node) { + if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) + return false; + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; + if (!decl || !ts.isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { + return false; + } + var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); + if (!globalPromiseSymbol) + return false; + var constructorSymbol = getSymbolAtLocation(decl.parent.parent.expression, /*ignoreErrors*/ true); + return constructorSymbol === globalPromiseSymbol; + } function getArgumentArityError(node, signatures, args) { var min = Number.POSITIVE_INFINITY; var max = Number.NEGATIVE_INFINITY; @@ -66519,9 +68310,15 @@ var ts; } var spanArray; var related; - var error = hasRestParameter || hasSpreadArgument ? hasRestParameter && hasSpreadArgument ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 : - ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : ts.Diagnostics.Expected_0_arguments_but_got_1; + var error = hasRestParameter || hasSpreadArgument ? + hasRestParameter && hasSpreadArgument ? + ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : + hasRestParameter ? + ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 : + ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : + paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? + ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : + ts.Diagnostics.Expected_0_arguments_but_got_1; if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; if (paramDecl) { @@ -66584,8 +68381,8 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 202 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 160 /* Decorator */; + var isTaggedTemplate = node.kind === 205 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 161 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; @@ -66647,7 +68444,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 200 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 203 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -66659,10 +68456,10 @@ var ts; // is just important for choosing the best signature. So in the case where there is only one // signature, the subtype pass is useless. So skipping it is an optimization. if (candidates.length > 1) { - result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); + result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma); } if (!result) { - result = chooseOverload(candidates, assignableRelation, signatureHelpTrailingComma); + result = chooseOverload(candidates, assignableRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma); } if (result) { return result; @@ -66687,6 +68484,7 @@ var ts; if (last_2.declaration && candidatesForArgumentError.length > 3) { ts.addRelatedInfo(d, ts.createDiagnosticForNode(last_2.declaration, ts.Diagnostics.The_last_overload_is_declared_here)); } + addImplementationSuccessElaboration(last_2, d); diagnostics.add(d); } } @@ -66700,7 +68498,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_20 = function (c) { + var _loop_21 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -66718,19 +68516,24 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_20(c); + _loop_21(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); - var related = ts.flatMap(diags_3, function (d) { return d.relatedInformation; }); + // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input + // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic + var related = __spreadArrays(ts.flatMap(diags_3, function (d) { return d.relatedInformation; })); + var diag = void 0; if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) { var _b = diags_3[0], file = _b.file, start = _b.start, length_6 = _b.length; - diagnostics.add({ file: file, start: start, length: length_6, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }); + diag = { file: file, start: start, length: length_6, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }; } else { - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, chain, related)); + diag = ts.createDiagnosticForNodeFromMessageChain(node, chain, related); } + addImplementationSuccessElaboration(candidatesForArgumentError[0], diag); + diagnostics.add(diag); } } else if (candidateForArgumentArityError) { @@ -66753,7 +68556,26 @@ var ts; } } return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); - function chooseOverload(candidates, relation, signatureHelpTrailingComma) { + function addImplementationSuccessElaboration(failed, diagnostic) { + var _a, _b; + var oldCandidatesForArgumentError = candidatesForArgumentError; + var oldCandidateForArgumentArityError = candidateForArgumentArityError; + var oldCandidateForTypeArgumentError = candidateForTypeArgumentError; + var declCount = ts.length((_a = failed.declaration) === null || _a === void 0 ? void 0 : _a.symbol.declarations); + var isOverload = declCount > 1; + var implDecl = isOverload ? ts.find(((_b = failed.declaration) === null || _b === void 0 ? void 0 : _b.symbol.declarations) || ts.emptyArray, function (d) { return ts.isFunctionLikeDeclaration(d) && ts.nodeIsPresent(d.body); }) : undefined; + if (implDecl) { + var candidate = getSignatureFromDeclaration(implDecl); + var isSingleNonGenericCandidate_1 = !candidate.typeParameters; + if (chooseOverload([candidate], assignableRelation, isSingleNonGenericCandidate_1)) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(implDecl, ts.Diagnostics.The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible)); + } + } + candidatesForArgumentError = oldCandidatesForArgumentError; + candidateForArgumentArityError = oldCandidateForArgumentArityError; + candidateForTypeArgumentError = oldCandidateForTypeArgumentError; + } + function chooseOverload(candidates, relation, isSingleNonGenericCandidate, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } candidatesForArgumentError = undefined; candidateForArgumentArityError = undefined; @@ -66852,7 +68674,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_21 = function (i) { + var _loop_22 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -66860,7 +68682,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_21(i); + _loop_22(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0 /* None */; @@ -67163,7 +68985,7 @@ var ts; var declaration = signature.declaration; var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 165 /* Constructor */) { + if (!modifiers || declaration.kind !== 166 /* Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -67195,8 +69017,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var constituent = types_18[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var constituent = types_19[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -67292,6 +69114,11 @@ var ts; return resolveUntypedCall(node); } if (!callSignatures.length) { + if (ts.isArrayLiteralExpression(node.parent)) { + var diagnostic = ts.createDiagnosticForNode(node.tag, ts.Diagnostics.It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked); + diagnostics.add(diagnostic); + return resolveErrorCall(node); + } invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } @@ -67302,16 +69129,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 159 /* Parameter */: + case 160 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -67370,6 +69197,10 @@ var ts; var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + if (ts.length(node.typeArguments)) { + ts.forEach(node.typeArguments, checkSourceElement); + diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); + } return fakeSignature; } var exprTypes = checkExpression(node.tagName); @@ -67402,16 +69233,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 200 /* CallExpression */: + case 203 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 201 /* NewExpression */: + case 204 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 160 /* Decorator */: + case 161 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 272 /* JsxOpeningElement */: - case 271 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: + case 274 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -67489,20 +69320,61 @@ var ts; } } function getAssignedClassSymbol(decl) { - var assignmentSymbol = decl && decl.parent && - (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || - ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || - ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); - var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); - var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); + var _a; + var assignmentSymbol = decl && getSymbolOfExpando(decl, /*allowDeclaration*/ true); + var prototype = (_a = assignmentSymbol === null || assignmentSymbol === void 0 ? void 0 : assignmentSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("prototype"); + var init = (prototype === null || prototype === void 0 ? void 0 : prototype.valueDeclaration) && getAssignedJSPrototype(prototype.valueDeclaration); return init ? getSymbolOfNode(init) : undefined; } + function getSymbolOfExpando(node, allowDeclaration) { + if (!node.parent) { + return undefined; + } + var name; + var decl; + if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) { + if (!ts.isInJSFile(node) && !(ts.isVarConst(node.parent) && ts.isFunctionLikeDeclaration(node))) { + return undefined; + } + name = node.parent.name; + decl = node.parent; + } + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + name = parentNode.left; + decl = name; + } + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !ts.isBindableStaticNameExpression(name) || !ts.isSameEntityName(name, parentNode.left)) { + return undefined; + } + } + } + else if (allowDeclaration && ts.isFunctionDeclaration(node)) { + name = node.name; + decl = node; + } + if (!decl || !name || (!allowDeclaration && !ts.getExpandoInitializer(node, ts.isPrototypeAccess(name)))) { + return undefined; + } + return getSymbolOfNode(decl); + } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 198 /* PropertyAccessExpression */) { + while (parent && parent.kind === 201 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { @@ -67529,12 +69401,12 @@ var ts; if (node.expression.kind === 105 /* SuperKeyword */) { return voidType; } - if (node.kind === 201 /* NewExpression */) { + if (node.kind === 204 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 165 /* Constructor */ && - declaration.kind !== 169 /* ConstructSignature */ && - declaration.kind !== 174 /* ConstructorType */ && + declaration.kind !== 166 /* Constructor */ && + declaration.kind !== 170 /* ConstructSignature */ && + declaration.kind !== 175 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -67554,7 +69426,7 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 200 /* CallExpression */ && node.parent.kind === 230 /* ExpressionStatement */ && + if (node.kind === 203 /* CallExpression */ && node.parent.kind === 233 /* ExpressionStatement */ && returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); @@ -67565,14 +69437,11 @@ var ts; } } if (ts.isInJSFile(node)) { - var decl = ts.getDeclarationOfExpando(node); - if (decl) { - var jsSymbol = getSymbolOfNode(decl); - if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { - var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); - jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; - return getIntersectionType([returnType, jsAssignmentType]); - } + var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); + if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; @@ -67586,20 +69455,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 200 /* CallExpression */: - case 160 /* Decorator */: - case 201 /* NewExpression */: + case 203 /* CallExpression */: + case 161 /* Decorator */: + case 204 /* NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 272 /* JsxOpeningElement */: - case 271 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: + case 274 /* JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: return node.argumentExpression; - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return node.name; - case 172 /* TypeReference */: + case 173 /* TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -67658,6 +69527,7 @@ var ts; if (hasSyntheticDefault) { var memberTable = ts.createSymbolTable(); var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + newSymbol.parent = originalSymbol; newSymbol.nameType = getLiteralType("default"); newSymbol.target = resolveSymbol(symbol); memberTable.set("default" /* Default */, newSymbol); @@ -67690,9 +69560,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 248 /* FunctionDeclaration */ + ? 251 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 246 /* VariableDeclaration */ + ? 249 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -67722,18 +69592,19 @@ var ts; case 9 /* BigIntLiteral */: case 109 /* TrueKeyword */: case 94 /* FalseKeyword */: - case 196 /* ArrayLiteralExpression */: - case 197 /* ObjectLiteralExpression */: + case 199 /* ArrayLiteralExpression */: + case 200 /* ObjectLiteralExpression */: + case 218 /* TemplateExpression */: return true; - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -67789,7 +69660,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 165 /* Constructor */) { + else if (container.kind === 166 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -67799,8 +69670,8 @@ var ts; } } function checkImportMetaProperty(node) { - if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); + if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system); } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); @@ -67836,7 +69707,7 @@ var ts; return restParameter.escapedName; } function isValidDeclarationForTupleLabel(d) { - return d.kind === 191 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 192 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -67909,21 +69780,40 @@ var ts; } return length; } - function getMinArgumentCount(signature, strongArityForUntypedJS) { - if (signatureHasRestParameter(signature)) { - var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); - if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); - var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; - if (requiredCount > 0) { - return signature.parameters.length - 1 + requiredCount; + function getMinArgumentCount(signature, flags) { + var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { + var minArgumentCount = void 0; + if (signatureHasRestParameter(signature)) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; + if (requiredCount > 0) { + minArgumentCount = signature.parameters.length - 1 + requiredCount; + } } } + if (minArgumentCount === undefined) { + if (!strongArityForUntypedJS && signature.flags & 16 /* IsUntypedSignatureInJSFile */) { + return 0; + } + minArgumentCount = signature.minArgumentCount; + } + if (voidIsNonOptional) { + return minArgumentCount; + } + for (var i = minArgumentCount - 1; i >= 0; i--) { + var type = getTypeAtPosition(signature, i); + if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + break; + } + minArgumentCount = i; + } + signature.resolvedMinArgumentCount = minArgumentCount; } - if (!strongArityForUntypedJS && signature.flags & 16 /* IsUntypedSignatureInJSFile */) { - return 0; - } - return signature.minArgumentCount; + return signature.resolvedMinArgumentCount; } function hasEffectiveRestParameter(signature) { if (signatureHasRestParameter(signature)) { @@ -68089,7 +69979,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 227 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 230 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -68274,7 +70164,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 208 /* TypeOfExpression */) { + if (node.expression.kind === 211 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. @@ -68337,11 +70227,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return true; - case 164 /* MethodDeclaration */: - return func.parent.kind === 197 /* ObjectLiteralExpression */; + case 165 /* MethodDeclaration */: + return func.parent.kind === 200 /* ObjectLiteralExpression */; default: return false; } @@ -68367,7 +70257,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 163 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 227 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 164 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 230 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; @@ -68400,7 +70290,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 164 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -68424,7 +70314,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 205 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 208 /* FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -68470,7 +70360,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 164 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -68483,7 +70373,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 227 /* Block */) { + if (node.body.kind === 230 /* Block */) { checkSourceElement(node.body); } else { @@ -68573,7 +70463,7 @@ var ts; expr.expression.kind === 107 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 165 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 166 /* Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -68598,7 +70488,7 @@ var ts; var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 260 /* NamespaceImport */; + return !!declaration && declaration.kind === 263 /* NamespaceImport */; } } } @@ -68679,7 +70569,7 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(node); - if (func && func.kind !== 165 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { + if (func && func.kind !== 166 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -68781,8 +70671,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { - var t = types_19[_i]; + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var t = types_20[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -68799,7 +70689,7 @@ var ts; } return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 132 /* StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || @@ -68848,8 +70738,8 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(allTypesAssignableToKind(leftType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { @@ -68872,7 +70762,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 285 /* PropertyAssignment */ || property.kind === 286 /* ShorthandPropertyAssignment */) { + if (property.kind === 288 /* PropertyAssignment */ || property.kind === 289 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -68883,11 +70773,11 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 286 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 289 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 287 /* SpreadAssignment */) { + else if (property.kind === 290 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -68921,23 +70811,28 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { - checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); + var type = possiblyOutOfBoundsType; + if (node.elements[i].kind === 220 /* SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + } + checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } return sourceType; } function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 219 /* OmittedExpression */) { - if (element.kind !== 217 /* SpreadElement */) { + if (element.kind !== 222 /* OmittedExpression */) { + if (element.kind !== 220 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = hasDefaultValue(element) ? 8 /* NoTupleBoundsCheck */ : 0; - var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, createSyntheticExpression(element, indexType), accessFlags) || errorType; + var accessFlags = 16 /* ExpressionPosition */ | (hasDefaultValue(element) ? 8 /* NoTupleBoundsCheck */ : 0); + var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType; var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); @@ -68949,7 +70844,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 213 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { + if (restExpression.kind === 216 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -68965,7 +70860,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 286 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 289 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -68981,24 +70876,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 213 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { + if (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 197 /* ObjectLiteralExpression */) { + if (target.kind === 200 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 196 /* ArrayLiteralExpression */) { + if (target.kind === 199 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 287 /* SpreadAssignment */ ? + var error = target.parent.kind === 290 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 287 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 290 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { @@ -69023,36 +70918,36 @@ var ts; case 78 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 202 /* TaggedTemplateExpression */: - case 215 /* TemplateExpression */: + case 205 /* TaggedTemplateExpression */: + case 218 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 109 /* TrueKeyword */: case 94 /* FalseKeyword */: case 103 /* NullKeyword */: - case 149 /* UndefinedKeyword */: - case 205 /* FunctionExpression */: - case 218 /* ClassExpression */: - case 206 /* ArrowFunction */: - case 196 /* ArrayLiteralExpression */: - case 197 /* ObjectLiteralExpression */: - case 208 /* TypeOfExpression */: - case 222 /* NonNullExpression */: - case 271 /* JsxSelfClosingElement */: - case 270 /* JsxElement */: + case 150 /* UndefinedKeyword */: + case 208 /* FunctionExpression */: + case 221 /* ClassExpression */: + case 209 /* ArrowFunction */: + case 199 /* ArrayLiteralExpression */: + case 200 /* ObjectLiteralExpression */: + case 211 /* TypeOfExpression */: + case 225 /* NonNullExpression */: + case 274 /* JsxSelfClosingElement */: + case 273 /* JsxElement */: return true; - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 211 /* PrefixUnaryExpression */: - case 212 /* PostfixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -69064,9 +70959,9 @@ var ts; } return false; // Some forms listed here for clarity - case 209 /* VoidExpression */: // Explicit opt-out - case 203 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 221 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 212 /* VoidExpression */: // Explicit opt-out + case 206 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 224 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -69098,7 +70993,7 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (node.left.kind === 197 /* ObjectLiteralExpression */ || node.left.kind === 196 /* ArrayLiteralExpression */)) { + if (operator === 62 /* EqualsToken */ && (node.left.kind === 200 /* ObjectLiteralExpression */ || node.left.kind === 199 /* ArrayLiteralExpression */)) { finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107 /* ThisKeyword */)); break; } @@ -69165,7 +71060,7 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (left.kind === 197 /* ObjectLiteralExpression */ || left.kind === 196 /* ArrayLiteralExpression */)) { + if (operator === 62 /* EqualsToken */ && (left.kind === 200 /* ObjectLiteralExpression */ || left.kind === 199 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107 /* ThisKeyword */); } var leftType; @@ -69258,7 +71153,7 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 132 /* StringLike */) && !isTypeAssignableToKind(rightType, 132 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } @@ -69272,7 +71167,7 @@ var ts; // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 132 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 132 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -69290,7 +71185,7 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); @@ -69591,20 +71486,21 @@ var ts; return getUnionType([type1, type2], 2 /* Subtype */); } function checkTemplateExpression(node) { - // We just want to check each expressions, but we are unconcerned with - // the type of each expression, as any value may be coerced into a string. - // It is worth asking whether this is what we really want though. - // A place where we actually *are* concerned with the expressions' types are - // in tagged templates. - ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288 /* ESSymbolLike */)) { - error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); + var texts = [node.head.text]; + var types = []; + for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { + var span = _a[_i]; + var type = checkExpression(span.expression); + if (maybeTypeOfKind(type, 12288 /* ESSymbolLike */)) { + error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } - }); - return stringType; + texts.push(span.literal.text); + types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); + } + return isConstContext(node) ? getTemplateLiteralType(texts, types) : stringType; } function getContextNode(node) { - if (node.kind === 278 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 281 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -69653,13 +71549,13 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 203 /* TypeAssertionExpression */ || node.kind === 221 /* AsExpression */; + return node.kind === 206 /* TypeAssertionExpression */ || node.kind === 224 /* AsExpression */; } function checkDeclarationInitializer(declaration, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer)); - return ts.isParameter(declaration) && declaration.name.kind === 194 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 197 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -69669,7 +71565,7 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 195 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 198 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); elementFlags.push(2 /* Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { @@ -69712,7 +71608,7 @@ var ts; } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || + return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || @@ -69724,7 +71620,7 @@ var ts; var parent = node.parent; return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) || (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) || - (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent)) && isConstContext(parent.parent); + (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent) || ts.isTemplateSpan(parent)) && isConstContext(parent.parent); } function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) { var type = checkExpression(node, checkMode, forceTuple); @@ -69736,7 +71632,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 157 /* ComputedPropertyName */) { + if (node.name.kind === 158 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -69747,7 +71643,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 157 /* ComputedPropertyName */) { + if (node.name.kind === 158 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -69965,6 +71861,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { + ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -69974,6 +71871,7 @@ var ts; checkConstEnumAccess(node, type); } currentNode = saveCurrentNode; + ts.tracing.pop(); return type; } function checkConstEnumAccess(node, type) { @@ -69981,11 +71879,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 198 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 199 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 78 /* Identifier */ || node.kind === 156 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 175 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 267 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 202 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 176 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 270 /* ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } @@ -70010,9 +71908,9 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 218 /* ClassExpression */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 221 /* ClassExpression */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -70038,78 +71936,78 @@ var ts; return trueType; case 94 /* FalseKeyword */: return falseType; - case 215 /* TemplateExpression */: + case 218 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: return checkQualifiedName(node); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 200 /* CallExpression */: + case 203 /* CallExpression */: if (node.expression.kind === 99 /* ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 201 /* NewExpression */: + case 204 /* NewExpression */: return checkCallExpression(node, checkMode); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 218 /* ClassExpression */: + case 221 /* ClassExpression */: return checkClassExpression(node); - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 208 /* TypeOfExpression */: + case 211 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 203 /* TypeAssertionExpression */: - case 221 /* AsExpression */: + case 206 /* TypeAssertionExpression */: + case 224 /* AsExpression */: return checkAssertion(node); - case 222 /* NonNullExpression */: + case 225 /* NonNullExpression */: return checkNonNullAssertion(node); - case 223 /* MetaProperty */: + case 226 /* MetaProperty */: return checkMetaProperty(node); - case 207 /* DeleteExpression */: + case 210 /* DeleteExpression */: return checkDeleteExpression(node); - case 209 /* VoidExpression */: + case 212 /* VoidExpression */: return checkVoidExpression(node); - case 210 /* AwaitExpression */: + case 213 /* AwaitExpression */: return checkAwaitExpression(node); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 217 /* SpreadElement */: + case 220 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 219 /* OmittedExpression */: + case 222 /* OmittedExpression */: return undefinedWideningType; - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: return checkYieldExpression(node); - case 224 /* SyntheticExpression */: + case 227 /* SyntheticExpression */: return checkSyntheticExpression(node); - case 280 /* JsxExpression */: + case 283 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 270 /* JsxElement */: + case 273 /* JsxElement */: return checkJsxElement(node, checkMode); - case 271 /* JsxSelfClosingElement */: + case 274 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 274 /* JsxFragment */: + case 277 /* JsxFragment */: return checkJsxFragment(node); - case 278 /* JsxAttributes */: + case 281 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 272 /* JsxOpeningElement */: + case 275 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -70146,10 +72044,10 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 165 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 166 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 165 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 166 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -70160,13 +72058,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 165 /* Constructor */ || func.kind === 169 /* ConstructSignature */ || func.kind === 174 /* ConstructorType */) { + if (func.kind === 166 /* Constructor */ || func.kind === 170 /* ConstructSignature */ || func.kind === 175 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 206 /* ArrowFunction */) { + if (func.kind === 209 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 166 /* GetAccessor */ || func.kind === 167 /* SetAccessor */) { + if (func.kind === 167 /* GetAccessor */ || func.kind === 168 /* SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -70224,13 +72122,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 206 /* ArrowFunction */: - case 168 /* CallSignature */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 173 /* FunctionType */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 209 /* ArrowFunction */: + case 169 /* CallSignature */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 174 /* FunctionType */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -70248,7 +72146,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 194 /* ArrayBindingPattern */ || name.kind === 193 /* ObjectBindingPattern */) { + else if (name.kind === 197 /* ArrayBindingPattern */ || name.kind === 196 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -70257,13 +72155,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 170 /* IndexSignature */) { + if (node.kind === 171 /* IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 173 /* FunctionType */ || node.kind === 248 /* FunctionDeclaration */ || node.kind === 174 /* ConstructorType */ || - node.kind === 168 /* CallSignature */ || node.kind === 165 /* Constructor */ || - node.kind === 169 /* ConstructSignature */) { + else if (node.kind === 174 /* FunctionType */ || node.kind === 251 /* FunctionDeclaration */ || node.kind === 175 /* ConstructorType */ || + node.kind === 169 /* CallSignature */ || node.kind === 166 /* Constructor */ || + node.kind === 170 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -70293,10 +72191,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 169 /* ConstructSignature */: + case 170 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 168 /* CallSignature */: + case 169 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -70326,7 +72224,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 170 /* IndexSignature */ && node.kind !== 304 /* JSDocFunctionType */) { + if (node.kind !== 171 /* IndexSignature */ && node.kind !== 308 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -70338,7 +72236,7 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 165 /* Constructor */) { + if (member.kind === 166 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { @@ -70358,16 +72256,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 166 /* GetAccessor */: + case 167 /* GetAccessor */: addName(names, name, memberName, 1 /* GetAccessor */); break; - case 167 /* SetAccessor */: + case 168 /* SetAccessor */: addName(names, name, memberName, 2 /* SetAccessor */); break; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: addName(names, name, memberName, 8 /* Method */); break; } @@ -70430,7 +72328,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 161 /* PropertySignature */) { + if (member.kind === 162 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -70455,7 +72353,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 250 /* InterfaceDeclaration */) { + if (node.kind === 253 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -70475,7 +72373,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 146 /* StringKeyword */: + case 147 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -70483,7 +72381,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 143 /* NumberKeyword */: + case 144 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -70525,7 +72423,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 164 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -70553,7 +72451,7 @@ var ts; if (ts.isPrivateIdentifierPropertyDeclaration(n)) { return true; } - return n.kind === 162 /* PropertyDeclaration */ && + return n.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(n, 32 /* Static */) && !!n.initializer; } @@ -70584,7 +72482,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { var statement = statements_4[_i]; - if (statement.kind === 230 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 233 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -70609,7 +72507,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 166 /* GetAccessor */) { + if (node.kind === 167 /* GetAccessor */) { if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -70619,7 +72517,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 157 /* ComputedPropertyName */) { + if (node.name.kind === 158 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (ts.isPrivateIdentifier(node.name)) { @@ -70628,7 +72526,7 @@ var ts; if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 166 /* GetAccessor */ ? 167 /* SetAccessor */ : 166 /* GetAccessor */; + var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getEffectiveModifierFlags(node); @@ -70646,7 +72544,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 166 /* GetAccessor */) { + if (node.kind === 167 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -70694,7 +72592,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 172 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 173 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -70743,25 +72641,27 @@ var ts; function checkTupleType(node) { var elementTypes = node.elements; var seenOptionalElement = false; + var seenRestElement = false; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind !== 191 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 192 /* NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); if (flags & 8 /* Variadic */) { - if (!isArrayLikeType(getTypeFromTypeNode(e.type))) { + var type = getTypeFromTypeNode(e.type); + if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + seenRestElement = true; + } } else if (flags & 4 /* Rest */) { - if (i !== elementTypes.length - 1) { - grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); - break; - } + seenRestElement = true; } else if (flags & 2 /* Optional */) { seenOptionalElement = true; @@ -70770,11 +72670,17 @@ var ts; grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); break; } + if (seenRestElement && i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } } ts.forEach(node.elements, checkSourceElement); + getTypeFromTypeNode(node); } function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); + getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { if (!(type.flags & 8388608 /* IndexedAccess */)) { @@ -70784,7 +72690,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 199 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 202 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -70816,13 +72722,20 @@ var ts; } function checkMappedType(node) { checkSourceElement(node.typeParameter); + checkSourceElement(node.nameType); checkSourceElement(node.type); if (!node.type) { reportImplicitAny(node, anyType); } var type = getTypeFromMappedTypeNode(node); - var constraintType = getConstraintTypeFromMappedType(type); - checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter)); + var nameType = getNameTypeFromMappedType(type); + if (nameType) { + checkTypeAssignableTo(nameType, keyofConstraintType, node.nameType); + } + else { + var constraintType = getConstraintTypeFromMappedType(type); + checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter)); + } } function checkThisType(node) { getTypeFromThisTypeNode(node); @@ -70835,12 +72748,21 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 183 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); registerForUnusedIdentifiersCheck(node); } + function checkTemplateLiteralType(node) { + for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { + var span = _a[_i]; + checkSourceElement(span.type); + var type = getTypeFromTypeNode(span.type); + checkTypeAssignableTo(type, templateConstraintType, span.type); + } + getTypeFromTypeNode(node); + } function checkImportType(node) { checkSourceElement(node.argument); getTypeFromTypeNode(node); @@ -70849,10 +72771,10 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 179 /* OptionalType */) { + if (node.type.kind === 180 /* OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 180 /* RestType */) { + if (node.type.kind === 181 /* RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); @@ -70865,9 +72787,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 250 /* InterfaceDeclaration */ && - n.parent.kind !== 249 /* ClassDeclaration */ && - n.parent.kind !== 218 /* ClassExpression */ && + if (n.parent.kind !== 253 /* InterfaceDeclaration */ && + n.parent.kind !== 252 /* ClassDeclaration */ && + n.parent.kind !== 221 /* ClassExpression */ && n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported @@ -70963,7 +72885,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 164 /* MethodDeclaration */ || node.kind === 163 /* MethodSignature */) && + var reportError = (node.kind === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */) && ts.hasSyntacticModifier(node, 32 /* Static */) !== ts.hasSyntacticModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -71004,7 +72926,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 8388608 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 250 /* InterfaceDeclaration */ || node.parent.kind === 176 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 /* InterfaceDeclaration */ || node.parent.kind === 177 /* TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -71015,10 +72937,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 249 /* ClassDeclaration */ || node.kind === 218 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 248 /* FunctionDeclaration */ || node.kind === 164 /* MethodDeclaration */ || node.kind === 163 /* MethodSignature */ || node.kind === 165 /* Constructor */) { + if (node.kind === 251 /* FunctionDeclaration */ || node.kind === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */ || node.kind === 166 /* Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -71151,25 +73073,25 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 327 /* JSDocTypedefTag */: - case 320 /* JSDocCallbackTag */: - case 321 /* JSDocEnumTag */: + case 331 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: + case 325 /* JSDocEnumTag */: return 2 /* ExportType */; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 249 /* ClassDeclaration */: - case 252 /* EnumDeclaration */: - case 288 /* EnumMember */: + case 252 /* ClassDeclaration */: + case 255 /* EnumDeclaration */: + case 291 /* EnumMember */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 294 /* SourceFile */: + case 297 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -71177,17 +73099,17 @@ var ts; d = d.expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 257 /* ImportEqualsDeclaration */: - case 260 /* NamespaceImport */: - case 259 /* ImportClause */: - var result_11 = 0 /* None */; + case 260 /* ImportEqualsDeclaration */: + case 263 /* NamespaceImport */: + case 262 /* ImportClause */: + var result_12 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_11 |= getDeclarationSpaces(d); }); - return result_11; - case 246 /* VariableDeclaration */: - case 195 /* BindingElement */: - case 248 /* FunctionDeclaration */: - case 262 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); + return result_12; + case 249 /* VariableDeclaration */: + case 198 /* BindingElement */: + case 251 /* FunctionDeclaration */: + case 265 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` @@ -71480,24 +73402,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 159 /* Parameter */: + case 160 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -71544,30 +73466,30 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 182 /* IntersectionType */: - case 181 /* UnionType */: + case 183 /* IntersectionType */: + case 182 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 183 /* ConditionalType */: + case 184 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 185 /* ParenthesizedType */: - case 191 /* NamedTupleMember */: + case 186 /* ParenthesizedType */: + case 192 /* NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 172 /* TypeReference */: + case 173 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { - var typeNode = types_20[_i]; - while (typeNode.kind === 185 /* ParenthesizedType */ || typeNode.kind === 191 /* NamedTupleMember */) { + for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { + var typeNode = types_21[_i]; + while (typeNode.kind === 186 /* ParenthesizedType */ || typeNode.kind === 192 /* NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 140 /* NeverKeyword */) { + if (typeNode.kind === 141 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 190 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 149 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -71613,14 +73535,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 159 /* Parameter */) { + if (node.kind === 160 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -71629,23 +73551,23 @@ var ts; } } break; - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - var otherKind = node.kind === 166 /* GetAccessor */ ? 167 /* SetAccessor */ : 166 /* GetAccessor */; + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 159 /* Parameter */: + case 160 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -71708,7 +73630,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 156 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 157 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -71752,7 +73674,7 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return node; - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -71765,7 +73687,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 157 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 158 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -71787,14 +73709,11 @@ var ts; checkFunctionOrConstructorSymbol(localSymbol); } if (symbol.parent) { - // run check once for the first declaration - if (ts.getDeclarationOfKind(symbol, node.kind) === node) { - // run check on export symbol to check that modifiers agree across all exported declarations - checkFunctionOrConstructorSymbol(symbol); - } + // run check on export symbol to check that modifiers agree across all exported declarations + checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 163 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 164 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -71836,42 +73755,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 294 /* SourceFile */: - case 253 /* ModuleDeclaration */: - case 227 /* Block */: - case 255 /* CaseBlock */: - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: + case 297 /* SourceFile */: + case 256 /* ModuleDeclaration */: + case 230 /* Block */: + case 258 /* CaseBlock */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 165 /* Constructor */: - case 205 /* FunctionExpression */: - case 248 /* FunctionDeclaration */: - case 206 /* ArrowFunction */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 166 /* Constructor */: + case 208 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 209 /* ArrowFunction */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 163 /* MethodSignature */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 251 /* TypeAliasDeclaration */: - case 250 /* InterfaceDeclaration */: + case 164 /* MethodSignature */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 254 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 184 /* InferType */: + case 185 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -71891,11 +73810,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 164 /* MethodDeclaration */: - case 162 /* PropertyDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - if (member.kind === 167 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 165 /* MethodDeclaration */: + case 163 /* PropertyDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + if (member.kind === 168 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -71906,7 +73825,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 165 /* Constructor */: + case 166 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { @@ -71914,8 +73833,8 @@ var ts; } } break; - case 170 /* IndexSignature */: - case 226 /* SemicolonClassElement */: + case 171 /* IndexSignature */: + case 229 /* SemicolonClassElement */: // Can't be private break; default: @@ -71942,7 +73861,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 184 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 185 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -72034,7 +73953,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 260 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 263 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -72052,7 +73971,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 246 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 247 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 250 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -72073,7 +73992,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 229 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 232 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -72087,22 +74006,22 @@ var ts; switch (name.kind) { case 78 /* Identifier */: return ts.idText(name); - case 194 /* ArrayBindingPattern */: - case 193 /* ObjectBindingPattern */: + case 197 /* ArrayBindingPattern */: + case 196 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 259 /* ImportClause */ || node.kind === 262 /* ImportSpecifier */ || node.kind === 260 /* NamespaceImport */; + return node.kind === 262 /* ImportClause */ || node.kind === 265 /* ImportSpecifier */ || node.kind === 263 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 259 /* ImportClause */ ? decl : decl.kind === 260 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 262 /* ImportClause */ ? decl : decl.kind === 263 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 227 /* Block */) { + if (node.kind === 230 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -72132,12 +74051,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 162 /* PropertyDeclaration */ || - node.kind === 161 /* PropertySignature */ || - node.kind === 164 /* MethodDeclaration */ || - node.kind === 163 /* MethodSignature */ || - node.kind === 166 /* GetAccessor */ || - node.kind === 167 /* SetAccessor */) { + if (node.kind === 163 /* PropertyDeclaration */ || + node.kind === 162 /* PropertySignature */ || + node.kind === 165 /* MethodDeclaration */ || + node.kind === 164 /* MethodSignature */ || + node.kind === 167 /* GetAccessor */ || + node.kind === 168 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -72146,7 +74065,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 159 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 160 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -72203,7 +74122,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 294 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -72218,7 +74137,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 294 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -72253,7 +74172,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 246 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 249 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -72265,17 +74184,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 247 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 229 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 232 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 227 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 254 /* ModuleBlock */ || - container.kind === 253 /* ModuleDeclaration */ || - container.kind === 294 /* SourceFile */); + (container.kind === 230 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 257 /* ModuleBlock */ || + container.kind === 256 /* ModuleDeclaration */ || + container.kind === 297 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -72306,18 +74225,18 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 157 /* ComputedPropertyName */) { + if (node.name.kind === 158 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 195 /* BindingElement */) { - if (node.parent.kind === 193 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 198 /* BindingElement */) { + if (node.parent.kind === 196 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 157 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 158 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -72338,19 +74257,19 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 194 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 197 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 159 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.isParameterDeclaration(node) && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 235 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -72376,7 +74295,12 @@ var ts; } return; } + // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); + if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true)) { + checkAliasSymbol(node); + return; + } var type = convertAutoToAny(getTypeOfSymbol(symbol)); if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer @@ -72387,7 +74311,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 235 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 238 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -72413,10 +74337,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 162 /* PropertyDeclaration */ && node.kind !== 161 /* PropertySignature */) { + if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 246 /* VariableDeclaration */ || node.kind === 195 /* BindingElement */) { + if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -72428,7 +74352,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 162 /* PropertyDeclaration */ || nextDeclaration.kind === 161 /* PropertySignature */ + var message = nextDeclaration.kind === 163 /* PropertyDeclaration */ || nextDeclaration.kind === 162 /* 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; var declName = ts.declarationNameToString(nextDeclarationName); @@ -72438,8 +74362,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 159 /* Parameter */ && right.kind === 246 /* VariableDeclaration */) || - (left.kind === 246 /* VariableDeclaration */ && right.kind === 159 /* Parameter */)) { + if ((left.kind === 160 /* Parameter */ && right.kind === 249 /* VariableDeclaration */) || + (left.kind === 249 /* VariableDeclaration */ && right.kind === 160 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -72455,8 +74379,10 @@ var ts; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { + ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); checkGrammarVariableDeclaration(node); - return checkVariableLikeDeclaration(node); + checkVariableLikeDeclaration(node); + ts.tracing.pop(); } function checkBindingElement(node) { checkGrammarBindingElement(node); @@ -72479,7 +74405,7 @@ var ts; var type = checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableType(node.expression, node.thenStatement, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 228 /* EmptyStatement */) { + if (node.thenStatement.kind === 231 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -72572,12 +74498,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 247 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 250 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 247 /* VariableDeclarationList */) { + if (node.initializer.kind === 250 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -72611,14 +74537,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 247 /* VariableDeclarationList */) { + if (node.initializer.kind === 250 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 196 /* ArrayLiteralExpression */ || varExpr.kind === 197 /* ObjectLiteralExpression */) { + if (varExpr.kind === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -72650,7 +74576,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 247 /* VariableDeclarationList */) { + if (node.initializer.kind === 250 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -72664,7 +74590,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 196 /* ArrayLiteralExpression */ || varExpr.kind === 197 /* ObjectLiteralExpression */) { + if (varExpr.kind === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -72716,6 +74642,7 @@ var ts; } var uplevelIteration = languageVersion >= 2 /* ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); // Get the iterated type of an `Iterable<T>` or `IterableIterator<T>` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -72735,7 +74662,7 @@ var ts; } } if (iterationTypes || uplevelIteration) { - return iterationTypes && iterationTypes.yieldType; + return possibleOutOfBounds ? includeUndefinedInIndexSignature(iterationTypes && iterationTypes.yieldType) : (iterationTypes && iterationTypes.yieldType); } } var arrayType = inputType; @@ -72749,12 +74676,12 @@ var ts; // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2 /* Subtype */); } } - else if (arrayType.flags & 132 /* StringLike */) { + else if (arrayType.flags & 402653316 /* StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -72768,7 +74695,7 @@ var ts; // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. if (arrayType.flags & 131072 /* Never */) { - return stringType; + return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } } @@ -72793,17 +74720,17 @@ var ts; : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } - return hasStringConstituent ? stringType : undefined; + return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined; } var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 132 /* StringLike */) { + if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType([arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); } - return arrayElementType; + return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; } /** * Gets the requested "iteration type" from an `Iterable`-like or `AsyncIterable`-like type. @@ -72919,8 +74846,9 @@ var ts; if (iterationTypes_2 === noIterationTypes) { if (errorNode) { reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); - errorNode = undefined; } + setCachedIterationTypes(type, cacheKey, noIterationTypes); + return undefined; } else { allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); @@ -73198,6 +75126,7 @@ var ts; * record is returned. Otherwise, we return `undefined`. */ function getIterationTypesOfMethod(type, resolver, methodName, errorNode) { + var _a, _b, _c, _d; var method = getPropertyOfType(type, methodName); // Ignore 'return' or 'throw' if they are missing. if (!method && methodName !== "next") { @@ -73221,6 +75150,24 @@ var ts; } return methodName === "next" ? anyIterationTypes : undefined; } + // If the method signature comes exclusively from the global iterator or generator type, + // create iteration types from its type arguments like `getIterationTypesOfIteratorFast` + // does (so as to remove `undefined` from the next and return types). We arrive here when + // a contextual type for a generator was not a direct reference to one of those global types, + // but looking up `methodType` referred to one of them (and nothing else). E.g., in + // `interface SpecialIterator extends Iterator<number> {}`, `SpecialIterator` is not a + // reference to `Iterator`, but its `next` member derives exclusively from `Iterator`. + if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) { + var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false); + var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false); + var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol; + var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol; + if (isGeneratorMethod || isIteratorMethod) { + var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType; + var mapper = methodType.mapper; + return createIterationTypes(getMappedType(globalType.typeParameters[0], mapper), getMappedType(globalType.typeParameters[1], mapper), methodName === "next" ? getMappedType(globalType.typeParameters[2], mapper) : undefined); + } + } // Extract the first parameter and return type of each signature. var methodParameterTypes; var methodReturnTypes; @@ -73338,12 +75285,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 167 /* SetAccessor */) { + if (func.kind === 168 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 165 /* Constructor */) { + else if (func.kind === 166 /* Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -73361,7 +75308,7 @@ var ts; } } } - else if (func.kind !== 165 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 166 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -73390,7 +75337,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 282 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 285 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -73399,7 +75346,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 281 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 284 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -73431,7 +75378,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 242 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 245 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -73460,11 +75407,15 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.type && getTypeOfNode(catchClause.variableDeclaration) === errorType) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); + var declaration = catchClause.variableDeclaration; + if (declaration.type) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false); + if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); + } } - else if (catchClause.variableDeclaration.initializer) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); + else if (declaration.initializer) { + grammarErrorOnFirstToken(declaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { var blockLocals_1 = catchClause.block.locals; @@ -73541,8 +75492,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 213 /* BinaryExpression */ || - name.kind === 157 /* ComputedPropertyName */ || + (propDeclaration.kind === 216 /* BinaryExpression */ || + name.kind === 158 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -73619,7 +75570,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 172 /* TypeReference */) { + if (node.kind === 173 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -73730,6 +75681,7 @@ var ts; var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); checkTypeParameterListsIdentical(symbol); + checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. if (!(node.flags & 8388608 /* Ambient */)) { @@ -73820,7 +75772,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_22 = function (member) { + var _loop_23 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -73839,7 +75791,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_22(member); + _loop_23(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -73865,7 +75817,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 249 /* ClassDeclaration */ || d.kind === 250 /* InterfaceDeclaration */; + return d.kind === 252 /* ClassDeclaration */ || d.kind === 253 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -73920,7 +75872,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 218 /* ClassExpression */) { + if (derivedClassDecl.kind === 221 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -73941,7 +75893,7 @@ var ts; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 250 /* InterfaceDeclaration */ + || base.valueDeclaration && base.valueDeclaration.parent.kind === 253 /* InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment @@ -73956,7 +75908,7 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (compilerOptions.useDefineForClassFields) { - var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 162 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 /* PropertyDeclaration */ && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 128 /* Abstract */) @@ -74072,7 +76024,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 162 /* PropertyDeclaration */ && + return node.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -74096,7 +76048,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 250 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -74129,8 +76081,15 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - checkSourceElement(node.type); - registerForUnusedIdentifiersCheck(node); + if (node.type.kind === 136 /* IntrinsicKeyword */) { + if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { + error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); + } + } + else { + checkSourceElement(node.type); + registerForUnusedIdentifiersCheck(node); + } } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); @@ -74208,7 +76167,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -74218,7 +76177,7 @@ var ts; } } break; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -74247,7 +76206,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return evaluate(expr.expression); case 78 /* Identifier */: var identifier = expr; @@ -74255,14 +76214,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 199 /* ElementAccessExpression */: - case 198 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 198 /* PropertyAccessExpression */) { + if (ex.kind === 201 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -74295,8 +76254,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 78 /* Identifier */ || - node.kind === 198 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 199 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 201 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 202 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -74332,7 +76291,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 252 /* EnumDeclaration */) { + if (declaration.kind !== 255 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -74360,8 +76319,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 249 /* ClassDeclaration */ || - (declaration.kind === 248 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 252 /* ClassDeclaration */ || + (declaration.kind === 251 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } @@ -74424,7 +76383,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 249 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 252 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -74474,23 +76433,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 263 /* ExportAssignment */: - case 264 /* ExportDeclaration */: + case 266 /* ExportAssignment */: + case 267 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 257 /* ImportEqualsDeclaration */: - case 258 /* ImportDeclaration */: + case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 195 /* BindingElement */: - case 246 /* VariableDeclaration */: + case 198 /* BindingElement */: + case 249 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -74501,12 +76460,12 @@ var ts; break; } // falls through - case 249 /* ClassDeclaration */: - case 252 /* EnumDeclaration */: - case 248 /* FunctionDeclaration */: - case 250 /* InterfaceDeclaration */: - case 253 /* ModuleDeclaration */: - case 251 /* TypeAliasDeclaration */: + case 252 /* ClassDeclaration */: + case 255 /* EnumDeclaration */: + case 251 /* FunctionDeclaration */: + case 253 /* InterfaceDeclaration */: + case 256 /* ModuleDeclaration */: + case 254 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -74529,12 +76488,12 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return node; - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: do { node = node.left; } while (node.kind !== 78 /* Identifier */); return node; - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; @@ -74554,9 +76513,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 254 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 294 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 264 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 267 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -74590,14 +76549,14 @@ var ts; (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 267 /* ExportSpecifier */ ? + var message = node.kind === 270 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 267 /* ExportSpecifier */ + && node.kind === 270 /* ExportSpecifier */ && !node.parent.parent.isTypeOnly && !(target.flags & 111551 /* Value */) && !(node.flags & 8388608 /* Ambient */)) { @@ -74612,7 +76571,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); - if (node.kind === 262 /* ImportSpecifier */ && + if (node.kind === 265 /* ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && compilerOptions.esModuleInterop && moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { @@ -74634,7 +76593,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 260 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { // import * as ns from "foo"; @@ -74662,7 +76621,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 269 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 272 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { @@ -74702,10 +76661,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 254 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 254 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; - if (node.parent.kind !== 294 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -74738,14 +76697,14 @@ var ts; } function checkGrammarExportDeclaration(node) { var _a; - var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 265 /* NamedExports */; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268 /* NamedExports */; if (isTypeOnlyExportStar) { grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); } return !isTypeOnlyExportStar; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 294 /* SourceFile */ || node.parent.kind === 254 /* ModuleBlock */ || node.parent.kind === 253 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 297 /* SourceFile */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 256 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -74809,8 +76768,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 294 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 253 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -74835,6 +76794,9 @@ var ts; checkExpressionCached(node.expression); } } + else { + checkExpressionCached(node.expression); // doesn't resolve, check as expression to mark as error + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -74924,169 +76886,171 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 253 /* ModuleDeclaration */: - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 248 /* FunctionDeclaration */: + case 256 /* ModuleDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 251 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 229 /* FirstStatement */ && kind <= 245 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 232 /* FirstStatement */ && kind <= 248 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: return checkTypeParameter(node); - case 159 /* Parameter */: + case 160 /* Parameter */: return checkParameter(node); - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return checkPropertyDeclaration(node); - case 161 /* PropertySignature */: + case 162 /* PropertySignature */: return checkPropertySignature(node); - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 170 /* IndexSignature */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 171 /* IndexSignature */: return checkSignatureDeclaration(node); - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: return checkMethodDeclaration(node); - case 165 /* Constructor */: + case 166 /* Constructor */: return checkConstructorDeclaration(node); - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return checkAccessorDeclaration(node); - case 172 /* TypeReference */: + case 173 /* TypeReference */: return checkTypeReferenceNode(node); - case 171 /* TypePredicate */: + case 172 /* TypePredicate */: return checkTypePredicate(node); - case 175 /* TypeQuery */: + case 176 /* TypeQuery */: return checkTypeQuery(node); - case 176 /* TypeLiteral */: + case 177 /* TypeLiteral */: return checkTypeLiteral(node); - case 177 /* ArrayType */: + case 178 /* ArrayType */: return checkArrayType(node); - case 178 /* TupleType */: + case 179 /* TupleType */: return checkTupleType(node); - case 181 /* UnionType */: - case 182 /* IntersectionType */: + case 182 /* UnionType */: + case 183 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 185 /* ParenthesizedType */: - case 179 /* OptionalType */: - case 180 /* RestType */: + case 186 /* ParenthesizedType */: + case 180 /* OptionalType */: + case 181 /* RestType */: return checkSourceElement(node.type); - case 186 /* ThisType */: + case 187 /* ThisType */: return checkThisType(node); - case 187 /* TypeOperator */: + case 188 /* TypeOperator */: return checkTypeOperator(node); - case 183 /* ConditionalType */: + case 184 /* ConditionalType */: return checkConditionalType(node); - case 184 /* InferType */: + case 185 /* InferType */: return checkInferType(node); - case 192 /* ImportType */: + case 193 /* TemplateLiteralType */: + return checkTemplateLiteralType(node); + case 195 /* ImportType */: return checkImportType(node); - case 191 /* NamedTupleMember */: + case 192 /* NamedTupleMember */: return checkNamedTupleMember(node); - case 311 /* JSDocAugmentsTag */: + case 315 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 312 /* JSDocImplementsTag */: + case 316 /* JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 327 /* JSDocTypedefTag */: - case 320 /* JSDocCallbackTag */: - case 321 /* JSDocEnumTag */: + case 331 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: + case 325 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 326 /* JSDocTemplateTag */: + case 330 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 325 /* JSDocTypeTag */: + case 329 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 322 /* JSDocParameterTag */: + case 326 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 328 /* JSDocPropertyTag */: + case 333 /* JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 304 /* JSDocFunctionType */: + case 308 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 302 /* JSDocNonNullableType */: - case 301 /* JSDocNullableType */: - case 299 /* JSDocAllType */: - case 300 /* JSDocUnknownType */: - case 308 /* JSDocTypeLiteral */: + case 306 /* JSDocNonNullableType */: + case 305 /* JSDocNullableType */: + case 303 /* JSDocAllType */: + case 304 /* JSDocUnknownType */: + case 312 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 305 /* JSDocVariadicType */: + case 309 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 298 /* JSDocTypeExpression */: + case 301 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 188 /* IndexedAccessType */: + case 189 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 189 /* MappedType */: + case 190 /* MappedType */: return checkMappedType(node); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 227 /* Block */: - case 254 /* ModuleBlock */: + case 230 /* Block */: + case 257 /* ModuleBlock */: return checkBlock(node); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return checkVariableStatement(node); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return checkExpressionStatement(node); - case 231 /* IfStatement */: + case 234 /* IfStatement */: return checkIfStatement(node); - case 232 /* DoStatement */: + case 235 /* DoStatement */: return checkDoStatement(node); - case 233 /* WhileStatement */: + case 236 /* WhileStatement */: return checkWhileStatement(node); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return checkForStatement(node); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return checkForInStatement(node); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return checkForOfStatement(node); - case 237 /* ContinueStatement */: - case 238 /* BreakStatement */: + case 240 /* ContinueStatement */: + case 241 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: return checkReturnStatement(node); - case 240 /* WithStatement */: + case 243 /* WithStatement */: return checkWithStatement(node); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: return checkSwitchStatement(node); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return checkLabeledStatement(node); - case 243 /* ThrowStatement */: + case 246 /* ThrowStatement */: return checkThrowStatement(node); - case 244 /* TryStatement */: + case 247 /* TryStatement */: return checkTryStatement(node); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 195 /* BindingElement */: + case 198 /* BindingElement */: return checkBindingElement(node); - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: return checkClassDeclaration(node); - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return checkImportDeclaration(node); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return checkExportDeclaration(node); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return checkExportAssignment(node); - case 228 /* EmptyStatement */: - case 245 /* DebuggerStatement */: + case 231 /* EmptyStatement */: + case 248 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 268 /* MissingDeclaration */: + case 271 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -75181,43 +77145,46 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 200 /* CallExpression */: - case 201 /* NewExpression */: - case 202 /* TaggedTemplateExpression */: - case 160 /* Decorator */: - case 272 /* JsxOpeningElement */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: + case 205 /* TaggedTemplateExpression */: + case 161 /* Decorator */: + case 275 /* JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 218 /* ClassExpression */: + case 221 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 271 /* JsxSelfClosingElement */: + case 274 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 270 /* JsxElement */: + case 273 /* JsxElement */: checkJsxElementDeferred(node); break; } currentNode = saveCurrentNode; } function checkSourceFile(node) { + var tracingData = ["check" /* Check */, "checkSourceFile", { path: node.path }]; + ts.tracing.begin.apply(ts.tracing, tracingData); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); ts.performance.measure("Check", "beforeCheck", "afterCheck"); + ts.tracing.end.apply(ts.tracing, tracingData); } function unusedIsError(kind, isAmbient) { if (isAmbient) { @@ -75350,17 +77317,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 294 /* SourceFile */: + case 297 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 218 /* ClassExpression */: + case 221 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -75368,8 +77335,8 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -75378,7 +77345,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -75426,19 +77393,19 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 158 /* TypeParameter */: - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 252 /* EnumDeclaration */: - case 327 /* JSDocTypedefTag */: - case 320 /* JSDocCallbackTag */: - case 321 /* JSDocEnumTag */: + case 159 /* TypeParameter */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 255 /* EnumDeclaration */: + case 331 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: + case 325 /* JSDocEnumTag */: return true; - case 259 /* ImportClause */: + case 262 /* ImportClause */: return node.isTypeOnly; - case 262 /* ImportSpecifier */: - case 267 /* ExportSpecifier */: + case 265 /* ImportSpecifier */: + case 270 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -75446,16 +77413,25 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 156 /* QualifiedName */) { + while (node.parent.kind === 157 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 172 /* TypeReference */; + return node.parent.kind === 173 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 198 /* PropertyAccessExpression */) { + while (node.parent.kind === 201 /* PropertyAccessExpression */) { + node = node.parent; + } + return node.parent.kind === 223 /* ExpressionWithTypeArguments */; + } + function isJSDocEntryNameReference(node) { + while (node.parent.kind === 157 /* QualifiedName */) { + node = node.parent; + } + while (node.parent.kind === 201 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 220 /* ExpressionWithTypeArguments */; + return node.parent.kind === 302 /* JSDocNameReference */; } function forEachEnclosingClass(node, callback) { var result; @@ -75483,13 +77459,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 156 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 157 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 257 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 260 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 263 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 266 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -75515,7 +77491,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 192 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 195 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -75525,7 +77501,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 198 /* PropertyAccessExpression */ && + name.parent.kind === 201 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name)) { @@ -75535,7 +77511,7 @@ var ts; } } } - if (name.parent.kind === 263 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 266 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -75545,7 +77521,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 257 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 260 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -75563,7 +77539,7 @@ var ts; if (isHeritageClauseElementIdentifier(name)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 220 /* ExpressionWithTypeArguments */) { + if (name.parent.kind === 223 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { @@ -75579,10 +77555,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 322 /* JSDocParameterTag */) { + if (name.parent.kind === 326 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 158 /* TypeParameter */ && name.parent.parent.kind === 326 /* JSDocTemplateTag */) { + if (name.parent.kind === 159 /* TypeParameter */ && name.parent.parent.kind === 330 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -75599,12 +77575,12 @@ var ts; } return resolveEntityName(name, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (name.kind === 198 /* PropertyAccessExpression */ || name.kind === 156 /* QualifiedName */) { + else if (name.kind === 201 /* PropertyAccessExpression */ || name.kind === 157 /* QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 198 /* PropertyAccessExpression */) { + if (name.kind === 201 /* PropertyAccessExpression */) { checkPropertyAccessExpression(name); } else { @@ -75614,17 +77590,21 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 172 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 173 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (name.parent.kind === 171 /* TypePredicate */) { + else if (isJSDocEntryNameReference(name)) { + var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); + } + if (name.parent.kind === 172 /* TypePredicate */) { return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 294 /* SourceFile */) { + if (node.kind === 297 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -75647,8 +77627,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 195 /* BindingElement */ && - grandParent.kind === 193 /* ObjectBindingPattern */ && + else if (parent.kind === 198 /* BindingElement */ && + grandParent.kind === 196 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -75660,8 +77640,8 @@ var ts; switch (node.kind) { case 78 /* Identifier */: case 79 /* PrivateIdentifier */: - case 198 /* PropertyAccessExpression */: - case 156 /* QualifiedName */: + case 201 /* PropertyAccessExpression */: + case 157 /* QualifiedName */: return getSymbolOfNameOrPropertyAccessExpression(node); case 107 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -75675,14 +77655,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 186 /* ThisType */: + case 187 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 105 /* SuperKeyword */: return checkExpression(node).symbol; case 132 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 165 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 166 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -75693,7 +77673,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 258 /* ImportDeclaration */ || node.parent.kind === 264 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 261 /* ImportDeclaration */ || node.parent.kind === 267 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -75715,7 +77695,7 @@ var ts; case 38 /* EqualsGreaterThanToken */: case 83 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 192 /* ImportType */: + case 195 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; case 92 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; @@ -75724,18 +77704,26 @@ var ts; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 286 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 289 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } /** Returns the target of an export specifier without following aliases */ function getExportSpecifierLocalTargetSymbol(node) { - return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + if (ts.isExportSpecifier(node)) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node) : + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + } + else { + return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + } } function getTypeOfNode(node) { + if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { + return errorType; + } if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; @@ -75795,23 +77783,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 197 /* ObjectLiteralExpression */ || expr.kind === 196 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 200 /* ObjectLiteralExpression */ || expr.kind === 199 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 236 /* ForOfStatement */) { + if (expr.parent.kind === 239 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 213 /* BinaryExpression */) { + if (expr.parent.kind === 216 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 285 /* PropertyAssignment */) { + if (expr.parent.kind === 288 /* PropertyAssignment */) { var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType; var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent); @@ -75859,7 +77847,7 @@ var ts; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -75976,7 +77964,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 294 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 297 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -75991,6 +77979,9 @@ var ts; // When resolved as an expression identifier, if the given node references an import, return the declaration of // that import. Otherwise, return undefined. function getReferencedImportDeclaration(nodeIn) { + if (nodeIn.generatedImportReference) { + return nodeIn.generatedImportReference; + } var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); @@ -76004,7 +77995,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 284 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -76035,7 +78026,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 227 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 230 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -76076,19 +78067,19 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 259 /* ImportClause */: - case 260 /* NamespaceImport */: - case 262 /* ImportSpecifier */: - case 267 /* ExportSpecifier */: + case 262 /* ImportClause */: + case 263 /* NamespaceImport */: + case 265 /* ImportSpecifier */: + case 270 /* ExportSpecifier */: var symbol = getSymbolOfNode(node) || unknownSymbol; return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return node.expression && node.expression.kind === 78 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; @@ -76097,7 +78088,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 294 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 297 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -76204,15 +78195,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 288 /* EnumMember */: - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 291 /* EnumMember */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 288 /* EnumMember */) { + if (node.kind === 291 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -76278,7 +78269,7 @@ var ts; else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 132 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { @@ -76481,12 +78472,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 167 /* SetAccessor */ ? 166 /* GetAccessor */ : 167 /* SetAccessor */; + var otherKind = accessor.kind === 168 /* SetAccessor */ ? 167 /* GetAccessor */ : 168 /* SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 167 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 166 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 168 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 167 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -76502,7 +78493,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 294 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 297 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -76537,7 +78528,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 220 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 283 /* HeritageClause */; + return node.parent && node.parent.kind === 223 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 286 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -76549,7 +78540,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 198 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 201 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -76600,7 +78591,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 294 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 297 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -76628,12 +78619,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 253 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 256 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 294 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 297 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -76827,14 +78818,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 164 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 165 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 166 /* GetAccessor */ || node.kind === 167 /* SetAccessor */) { + else if (node.kind === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -76851,17 +78842,17 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 141 /* ReadonlyKeyword */) { - if (node.kind === 161 /* PropertySignature */ || node.kind === 163 /* MethodSignature */) { + if (modifier.kind !== 142 /* ReadonlyKeyword */) { + if (node.kind === 162 /* PropertySignature */ || node.kind === 164 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 170 /* IndexSignature */) { + if (node.kind === 171 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 84 /* ConstKeyword */: - if (node.kind !== 252 /* EnumDeclaration */) { + if (node.kind !== 255 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84 /* ConstKeyword */)); } break; @@ -76881,7 +78872,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 254 /* ModuleBlock */ || node.parent.kind === 294 /* SourceFile */) { + else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -76907,10 +78898,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 254 /* ModuleBlock */ || node.parent.kind === 294 /* SourceFile */) { + else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 159 /* Parameter */) { + else if (node.kind === 160 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -76922,11 +78913,11 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 141 /* ReadonlyKeyword */: + case 142 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 162 /* PropertyDeclaration */ && node.kind !== 161 /* PropertySignature */ && node.kind !== 170 /* IndexSignature */ && node.kind !== 159 /* Parameter */) { + else if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */ && node.kind !== 171 /* IndexSignature */ && node.kind !== 160 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } @@ -76947,16 +78938,16 @@ var ts; return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 159 /* Parameter */) { + else if (node.kind === 160 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 87 /* DefaultKeyword */: - var container = node.parent.kind === 294 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 253 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -76969,12 +78960,12 @@ var ts; return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 159 /* Parameter */) { + else if (node.kind === 160 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 254 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 257 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { @@ -76987,14 +78978,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 249 /* ClassDeclaration */) { - if (node.kind !== 164 /* MethodDeclaration */ && - node.kind !== 162 /* PropertyDeclaration */ && - node.kind !== 166 /* GetAccessor */ && - node.kind !== 167 /* SetAccessor */) { + if (node.kind !== 252 /* ClassDeclaration */) { + if (node.kind !== 165 /* MethodDeclaration */ && + node.kind !== 163 /* PropertyDeclaration */ && + node.kind !== 167 /* GetAccessor */ && + node.kind !== 168 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 249 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 252 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -77003,6 +78994,9 @@ var ts; if (flags & 8 /* Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } + if (flags & 256 /* Async */ && lastAsync) { + return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); + } } if (ts.isNamedDeclaration(node) && node.name.kind === 79 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); @@ -77016,15 +79010,18 @@ var ts; else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 159 /* Parameter */) { + else if (node.kind === 160 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } + if (flags & 128 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); + } flags |= 256 /* Async */; lastAsync = modifier; break; } } - if (node.kind === 165 /* Constructor */) { + if (node.kind === 166 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -77039,13 +79036,13 @@ var ts; } return false; } - else if ((node.kind === 258 /* ImportDeclaration */ || node.kind === 257 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 261 /* ImportDeclaration */ || node.kind === 260 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 159 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 159 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -77066,37 +79063,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 165 /* Constructor */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 170 /* IndexSignature */: - case 253 /* ModuleDeclaration */: - case 258 /* ImportDeclaration */: - case 257 /* ImportEqualsDeclaration */: - case 264 /* ExportDeclaration */: - case 263 /* ExportAssignment */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 159 /* Parameter */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 166 /* Constructor */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 171 /* IndexSignature */: + case 256 /* ModuleDeclaration */: + case 261 /* ImportDeclaration */: + case 260 /* ImportEqualsDeclaration */: + case 267 /* ExportDeclaration */: + case 266 /* ExportAssignment */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 160 /* Parameter */: return false; default: - if (node.parent.kind === 254 /* ModuleBlock */ || node.parent.kind === 294 /* SourceFile */) { + if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { return false; } switch (node.kind) { - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 129 /* AsyncKeyword */); - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 125 /* AbstractKeyword */); - case 250 /* InterfaceDeclaration */: - case 229 /* VariableStatement */: - case 251 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: + case 232 /* VariableStatement */: + case 254 /* TypeAliasDeclaration */: return true; - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 84 /* ConstKeyword */); default: ts.Debug.fail(); @@ -77109,10 +79106,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 164 /* MethodDeclaration */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 165 /* MethodDeclaration */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -77231,7 +79228,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 146 /* StringKeyword */ && parameter.type.kind !== 143 /* NumberKeyword */) { + if (parameter.type.kind !== 147 /* StringKeyword */ && parameter.type.kind !== 144 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -77273,7 +79270,7 @@ var ts; if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 219 /* OmittedExpression */) { + if (arg.kind === 222 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -77350,20 +79347,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 157 /* ComputedPropertyName */) { + if (node.kind !== 158 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 213 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 216 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 248 /* FunctionDeclaration */ || - node.kind === 205 /* FunctionExpression */ || - node.kind === 164 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 251 /* FunctionDeclaration */ || + node.kind === 208 /* FunctionExpression */ || + node.kind === 165 /* MethodDeclaration */); if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -77382,7 +79379,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 287 /* SpreadAssignment */) { + if (prop.kind === 290 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -77393,11 +79390,11 @@ var ts; continue; } var name = prop.name; - if (name.kind === 157 /* ComputedPropertyName */) { + if (name.kind === 158 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 286 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 289 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); @@ -77410,7 +79407,7 @@ var ts; // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 164 /* MethodDeclaration */) { + if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 165 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -77425,10 +79422,10 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -77436,13 +79433,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 166 /* GetAccessor */: + case 167 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 167 /* SetAccessor */: + case 168 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -77481,7 +79478,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 279 /* JsxSpreadAttribute */) { + if (attr.kind === 282 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -77491,7 +79488,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 280 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 283 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -77505,14 +79502,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 236 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 239 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 165 /* Constructor */) { + if (func && func.kind !== 166 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -77523,7 +79520,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 247 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 250 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -77538,20 +79535,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 235 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 238 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 235 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 238 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 235 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 238 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -77576,11 +79573,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 166 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 167 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 167 /* SetAccessor */) { + if (accessor.kind === 168 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -77602,17 +79599,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 166 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 167 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 166 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 167 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 150 /* UniqueKeyword */) { - if (node.type.kind !== 147 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(147 /* SymbolKeyword */)); + if (node.operator === 151 /* UniqueKeyword */) { + if (node.type.kind !== 148 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -77623,7 +79620,7 @@ var ts; } } switch (parent.kind) { - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 78 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -77635,13 +79632,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: if (!ts.hasSyntacticModifier(parent, 32 /* Static */) || !ts.hasEffectiveModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 161 /* PropertySignature */: + case 162 /* PropertySignature */: if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -77650,9 +79647,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 141 /* ReadonlyKeyword */) { - if (node.type.kind !== 177 /* ArrayType */ && node.type.kind !== 178 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(147 /* SymbolKeyword */)); + else if (node.operator === 142 /* ReadonlyKeyword */) { + if (node.type.kind !== 178 /* ArrayType */ && node.type.kind !== 179 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148 /* SymbolKeyword */)); } } } @@ -77665,8 +79662,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 164 /* MethodDeclaration */) { - if (node.parent.kind === 197 /* ObjectLiteralExpression */) { + if (node.kind === 165 /* MethodDeclaration */) { + if (node.parent.kind === 200 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 129 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -77694,14 +79691,14 @@ var ts; if (node.flags & 8388608 /* Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 164 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 165 /* MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 250 /* InterfaceDeclaration */) { + else if (node.parent.kind === 253 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 176 /* TypeLiteral */) { + else if (node.parent.kind === 177 /* TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -77712,11 +79709,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 237 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 240 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -77724,8 +79721,8 @@ var ts; return false; } break; - case 241 /* SwitchStatement */: - if (node.kind === 238 /* BreakStatement */ && !node.label) { + case 244 /* SwitchStatement */: + if (node.kind === 241 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -77740,13 +79737,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 238 /* BreakStatement */ + var message = node.kind === 241 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 238 /* BreakStatement */ + var message = node.kind === 241 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -77770,12 +79767,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 211 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 211 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -77806,7 +79803,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 235 /* ForInStatement */ && node.parent.parent.kind !== 236 /* ForOfStatement */) { + if (node.parent.parent.kind !== 238 /* ForInStatement */ && node.parent.parent.kind !== 239 /* ForOfStatement */) { if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } @@ -77819,8 +79816,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 229 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { - return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); + if (node.exclamationToken && (node.parent.parent.kind !== 232 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { + var message = node.initializer + ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions + : ts.Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations; + return grammarErrorOnNode(node.exclamationToken, message); } var moduleKind = ts.getEmitModuleKind(compilerOptions); if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System && @@ -77882,15 +79882,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 231 /* IfStatement */: - case 232 /* DoStatement */: - case 233 /* WhileStatement */: - case 240 /* WithStatement */: - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: + case 234 /* IfStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: + case 243 /* WithStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: return false; - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -77982,7 +79982,7 @@ var ts; return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 250 /* InterfaceDeclaration */) { + else if (node.parent.kind === 253 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -77990,7 +79990,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 176 /* TypeLiteral */) { + else if (node.parent.kind === 177 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -78003,7 +80003,12 @@ var ts; } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || node.flags & 8388608 /* Ambient */ || ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */))) { - return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); + var message = node.initializer + ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions + : !node.type + ? ts.Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations + : ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context; + return grammarErrorOnNode(node.exclamationToken, message); } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { @@ -78019,13 +80024,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 250 /* InterfaceDeclaration */ || - node.kind === 251 /* TypeAliasDeclaration */ || - node.kind === 258 /* ImportDeclaration */ || - node.kind === 257 /* ImportEqualsDeclaration */ || - node.kind === 264 /* ExportDeclaration */ || - node.kind === 263 /* ExportAssignment */ || - node.kind === 256 /* NamespaceExportDeclaration */ || + if (node.kind === 253 /* InterfaceDeclaration */ || + node.kind === 254 /* TypeAliasDeclaration */ || + node.kind === 261 /* ImportDeclaration */ || + node.kind === 260 /* ImportEqualsDeclaration */ || + node.kind === 267 /* ExportDeclaration */ || + node.kind === 266 /* ExportAssignment */ || + node.kind === 259 /* NamespaceExportDeclaration */ || ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -78034,7 +80039,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 229 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 232 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -78057,7 +80062,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 227 /* Block */ || node.parent.kind === 254 /* ModuleBlock */ || node.parent.kind === 294 /* SourceFile */) { + if (node.parent.kind === 230 /* Block */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -78079,10 +80084,10 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 190 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 191 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 288 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 291 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -78257,14 +80262,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 248 /* FunctionDeclaration */ && declaration.kind !== 164 /* MethodDeclaration */) || + return (declaration.kind !== 251 /* FunctionDeclaration */ && declaration.kind !== 165 /* MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 262 /* ImportSpecifier */: - case 267 /* ExportSpecifier */: + case 265 /* ImportSpecifier */: + case 270 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -78272,14 +80277,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 259 /* ImportClause */: // For default import - case 257 /* ImportEqualsDeclaration */: - case 260 /* NamespaceImport */: - case 262 /* ImportSpecifier */: // For rename import `x as y` + case 262 /* ImportClause */: // For default import + case 260 /* ImportEqualsDeclaration */: + case 263 /* NamespaceImport */: + case 265 /* ImportSpecifier */: // For rename import `x as y` return true; case 78 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 262 /* ImportSpecifier */; + return decl.parent.kind === 265 /* ImportSpecifier */; default: return false; } @@ -78511,7 +80516,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 155 /* LastToken */) || kind === 186 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 156 /* LastToken */) || kind === 187 /* ThisType */) { return node; } var factory = context.factory; @@ -78519,287 +80524,291 @@ var ts; // Names case 78 /* Identifier */: return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 159 /* Parameter */: + case 160 /* Parameter */: return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 160 /* Decorator */: + case 161 /* Decorator */: return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 161 /* PropertySignature */: + case 162 /* PropertySignature */: return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 163 /* MethodSignature */: + case 164 /* MethodSignature */: return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 165 /* Constructor */: + case 166 /* Constructor */: return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 166 /* GetAccessor */: + case 167 /* GetAccessor */: return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 167 /* SetAccessor */: + case 168 /* SetAccessor */: return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 168 /* CallSignature */: + case 169 /* CallSignature */: return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* ConstructSignature */: + case 170 /* ConstructSignature */: return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 170 /* IndexSignature */: + case 171 /* IndexSignature */: return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 171 /* TypePredicate */: + case 172 /* TypePredicate */: return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 172 /* TypeReference */: + case 173 /* TypeReference */: return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 173 /* FunctionType */: + case 174 /* FunctionType */: return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 174 /* ConstructorType */: + case 175 /* ConstructorType */: return factory.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* TypeQuery */: + case 176 /* TypeQuery */: return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); - case 176 /* TypeLiteral */: + case 177 /* TypeLiteral */: return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 177 /* ArrayType */: + case 178 /* ArrayType */: return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 178 /* TupleType */: + case 179 /* TupleType */: return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 179 /* OptionalType */: + case 180 /* OptionalType */: return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* RestType */: + case 181 /* RestType */: return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* UnionType */: + case 182 /* UnionType */: return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 182 /* IntersectionType */: + case 183 /* IntersectionType */: return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 183 /* ConditionalType */: + case 184 /* ConditionalType */: return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 184 /* InferType */: + case 185 /* InferType */: return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 192 /* ImportType */: + case 195 /* ImportType */: return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 191 /* NamedTupleMember */: + case 192 /* NamedTupleMember */: return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 185 /* ParenthesizedType */: + case 186 /* ParenthesizedType */: return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* TypeOperator */: + case 188 /* TypeOperator */: return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 188 /* IndexedAccessType */: + case 189 /* IndexedAccessType */: return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 189 /* MappedType */: - return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 190 /* LiteralType */: + case 190 /* MappedType */: + return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 191 /* LiteralType */: return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); + case 193 /* TemplateLiteralType */: + return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); + case 194 /* TemplateLiteralTypeSpan */: + return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 193 /* ObjectBindingPattern */: + case 196 /* ObjectBindingPattern */: return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 194 /* ArrayBindingPattern */: + case 197 /* ArrayBindingPattern */: return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 195 /* BindingElement */: + case 198 /* BindingElement */: return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: if (node.flags & 32 /* OptionalChain */) { return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier)); } return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier)); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: if (node.flags & 32 /* OptionalChain */) { return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 200 /* CallExpression */: + case 203 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 201 /* NewExpression */: + case 204 /* NewExpression */: return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 203 /* TypeAssertionExpression */: + case 206 /* TypeAssertionExpression */: return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 207 /* DeleteExpression */: + case 210 /* DeleteExpression */: return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 208 /* TypeOfExpression */: + case 211 /* TypeOfExpression */: return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 209 /* VoidExpression */: + case 212 /* VoidExpression */: return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 210 /* AwaitExpression */: + case 213 /* AwaitExpression */: return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 215 /* TemplateExpression */: + case 218 /* TemplateExpression */: return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* SpreadElement */: + case 220 /* SpreadElement */: return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* ClassExpression */: + case 221 /* ClassExpression */: return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 221 /* AsExpression */: + case 224 /* AsExpression */: return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 222 /* NonNullExpression */: + case 225 /* NonNullExpression */: if (node.flags & 32 /* OptionalChain */) { return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 223 /* MetaProperty */: + case 226 /* MetaProperty */: return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 225 /* TemplateSpan */: + case 228 /* TemplateSpan */: return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 227 /* Block */: + case 230 /* Block */: return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* IfStatement */: + case 234 /* IfStatement */: return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 232 /* DoStatement */: + case 235 /* DoStatement */: return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 233 /* WhileStatement */: + case 236 /* WhileStatement */: return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isToken), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 237 /* ContinueStatement */: + case 240 /* ContinueStatement */: return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 238 /* BreakStatement */: + case 241 /* BreakStatement */: return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 240 /* WithStatement */: + case 243 /* WithStatement */: return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 243 /* ThrowStatement */: + case 246 /* ThrowStatement */: return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 244 /* TryStatement */: + case 247 /* TryStatement */: return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 247 /* VariableDeclarationList */: + case 250 /* VariableDeclarationList */: return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 254 /* ModuleBlock */: + case 257 /* ModuleBlock */: return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 255 /* CaseBlock */: + case 258 /* CaseBlock */: return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 256 /* NamespaceExportDeclaration */: + case 259 /* NamespaceExportDeclaration */: return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 259 /* ImportClause */: + case 262 /* ImportClause */: return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 266 /* NamespaceExport */: + case 269 /* NamespaceExport */: return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 261 /* NamedImports */: + case 264 /* NamedImports */: return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 265 /* NamedExports */: + case 268 /* NamedExports */: return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 267 /* ExportSpecifier */: + case 270 /* ExportSpecifier */: return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 269 /* ExternalModuleReference */: + case 272 /* ExternalModuleReference */: return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 270 /* JsxElement */: + case 273 /* JsxElement */: return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 271 /* JsxSelfClosingElement */: + case 274 /* JsxSelfClosingElement */: return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 272 /* JsxOpeningElement */: + case 275 /* JsxOpeningElement */: return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 273 /* JsxClosingElement */: + case 276 /* JsxClosingElement */: return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 274 /* JsxFragment */: + case 277 /* JsxFragment */: return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 277 /* JsxAttribute */: + case 280 /* JsxAttribute */: return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 278 /* JsxAttributes */: + case 281 /* JsxAttributes */: return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 279 /* JsxSpreadAttribute */: + case 282 /* JsxSpreadAttribute */: return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 280 /* JsxExpression */: + case 283 /* JsxExpression */: return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 281 /* CaseClause */: + case 284 /* CaseClause */: return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 282 /* DefaultClause */: + case 285 /* DefaultClause */: return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 283 /* HeritageClause */: + case 286 /* HeritageClause */: return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 287 /* SpreadAssignment */: + case 290 /* SpreadAssignment */: return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 288 /* EnumMember */: + case 291 /* EnumMember */: return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 294 /* SourceFile */: + case 297 /* SourceFile */: return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 331 /* PartiallyEmittedExpression */: + case 336 /* PartiallyEmittedExpression */: return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 332 /* CommaListExpression */: + case 337 /* CommaListExpression */: return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -79474,7 +81483,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 294 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 297 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -79525,7 +81534,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -79538,13 +81547,13 @@ var ts; hasImportDefault = true; } break; - case 257 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 269 /* ExternalModuleReference */) { + case 260 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 272 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -79575,13 +81584,13 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -79589,7 +81598,7 @@ var ts; } } break; - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default function() { } @@ -79609,7 +81618,7 @@ var ts; } } break; - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default class { } @@ -79783,7 +81792,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 162 /* PropertyDeclaration */ + return member.kind === 163 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -80002,18 +82011,27 @@ var ts; * for the element. */ function flattenBindingOrAssignmentElement(flattenContext, element, value, location, skipInitializer) { + var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element); // TODO: GH#18217 if (!skipInitializer) { var initializer = ts.visitNode(ts.getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, ts.isExpression); if (initializer) { // Combine value and initializer - value = value ? createDefaultValueCheck(flattenContext, value, initializer, location) : initializer; + if (value) { + value = createDefaultValueCheck(flattenContext, value, initializer, location); + // If 'value' is not a simple expression, it could contain side-effecting code that should evaluate before an object or array binding pattern. + if (!ts.isSimpleInlineableExpression(initializer) && ts.isBindingOrAssignmentPattern(bindingTarget)) { + value = ensureIdentifier(flattenContext, value, /*reuseIdentifierExpressions*/ true, location); + } + } + else { + value = initializer; + } } else if (!value) { // Use 'void 0' in absence of value and initializer value = flattenContext.context.factory.createVoidZero(); } } - var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element); // TODO: GH#18217 if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) { flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location); } @@ -80118,7 +82136,8 @@ var ts; if (flattenContext.level >= 1 /* ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (element.transformFlags & 16384 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); @@ -80152,6 +82171,20 @@ var ts; } } } + function isSimpleBindingOrAssignmentElement(element) { + var target = ts.getTargetOfBindingOrAssignmentElement(element); + if (!target || ts.isOmittedExpression(target)) + return true; + var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element); + if (propertyName && !ts.isPropertyNameLiteral(propertyName)) + return false; + var initializer = ts.getInitializerOfBindingOrAssignmentElement(element); + if (initializer && !ts.isSimpleInlineableExpression(initializer)) + return false; + if (ts.isBindingOrAssignmentPattern(target)) + return ts.every(ts.getElementsOfBindingOrAssignmentPattern(target), isSimpleBindingOrAssignmentElement); + return ts.isIdentifier(target); + } /** * Creates an expression used to provide a default value if a value is `undefined` at runtime. * @@ -80361,8 +82394,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(198 /* PropertyAccessExpression */); - context.enableSubstitution(199 /* ElementAccessExpression */); + context.enableSubstitution(201 /* PropertyAccessExpression */); + context.enableSubstitution(202 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -80388,14 +82421,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 295 /* Bundle */) { + if (node.kind === 298 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 297 /* InputFiles */) { + if (prepend.kind === 300 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -80446,16 +82479,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 294 /* SourceFile */: - case 255 /* CaseBlock */: - case 254 /* ModuleBlock */: - case 227 /* Block */: + case 297 /* SourceFile */: + case 258 /* CaseBlock */: + case 257 /* ModuleBlock */: + case 230 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 249 /* ClassDeclaration */: - case 248 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 251 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { break; } @@ -80467,7 +82500,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 249 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 252 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -80510,10 +82543,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: - case 257 /* ImportEqualsDeclaration */: - case 263 /* ExportAssignment */: - case 264 /* ExportDeclaration */: + case 261 /* ImportDeclaration */: + case 260 /* ImportEqualsDeclaration */: + case 266 /* ExportAssignment */: + case 267 /* ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -80534,13 +82567,13 @@ var ts; return node; } switch (node.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return visitImportDeclaration(node); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return visitExportAssignment(node); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -80560,11 +82593,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 264 /* ExportDeclaration */ || - node.kind === 258 /* ImportDeclaration */ || - node.kind === 259 /* ImportClause */ || - (node.kind === 257 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 269 /* ExternalModuleReference */)) { + if (node.kind === 267 /* ExportDeclaration */ || + node.kind === 261 /* ImportDeclaration */ || + node.kind === 262 /* ImportClause */ || + (node.kind === 260 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 272 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -80588,19 +82621,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 165 /* Constructor */: + case 166 /* Constructor */: return visitConstructor(node); - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 170 /* IndexSignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 164 /* MethodDeclaration */: + case 171 /* IndexSignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 165 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 226 /* SemicolonClassElement */: + case 229 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -80637,61 +82670,61 @@ var ts; case 125 /* AbstractKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: - case 141 /* ReadonlyKeyword */: + case 142 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 177 /* ArrayType */: - case 178 /* TupleType */: - case 179 /* OptionalType */: - case 180 /* RestType */: - case 176 /* TypeLiteral */: - case 171 /* TypePredicate */: - case 158 /* TypeParameter */: + case 178 /* ArrayType */: + case 179 /* TupleType */: + case 180 /* OptionalType */: + case 181 /* RestType */: + case 177 /* TypeLiteral */: + case 172 /* TypePredicate */: + case 159 /* TypeParameter */: case 128 /* AnyKeyword */: - case 151 /* UnknownKeyword */: + case 152 /* UnknownKeyword */: case 131 /* BooleanKeyword */: - case 146 /* StringKeyword */: - case 143 /* NumberKeyword */: - case 140 /* NeverKeyword */: + case 147 /* StringKeyword */: + case 144 /* NumberKeyword */: + case 141 /* NeverKeyword */: case 113 /* VoidKeyword */: - case 147 /* SymbolKeyword */: - case 174 /* ConstructorType */: - case 173 /* FunctionType */: - case 175 /* TypeQuery */: - case 172 /* TypeReference */: - case 181 /* UnionType */: - case 182 /* IntersectionType */: - case 183 /* ConditionalType */: - case 185 /* ParenthesizedType */: - case 186 /* ThisType */: - case 187 /* TypeOperator */: - case 188 /* IndexedAccessType */: - case 189 /* MappedType */: - case 190 /* LiteralType */: + case 148 /* SymbolKeyword */: + case 175 /* ConstructorType */: + case 174 /* FunctionType */: + case 176 /* TypeQuery */: + case 173 /* TypeReference */: + case 182 /* UnionType */: + case 183 /* IntersectionType */: + case 184 /* ConditionalType */: + case 186 /* ParenthesizedType */: + case 187 /* ThisType */: + case 188 /* TypeOperator */: + case 189 /* IndexedAccessType */: + case 190 /* MappedType */: + case 191 /* LiteralType */: // TypeScript type nodes are elided. // falls through - case 170 /* IndexSignature */: + case 171 /* IndexSignature */: // TypeScript index signatures are elided. // falls through - case 160 /* Decorator */: + case 161 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. // falls through - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 256 /* NamespaceExportDeclaration */: + case 259 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 165 /* Constructor */: + case 166 /* Constructor */: return visitConstructor(node); - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -80701,7 +82734,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 218 /* ClassExpression */: + case 221 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -80711,35 +82744,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 283 /* HeritageClause */: + case 286 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 166 /* GetAccessor */: + case 167 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 167 /* SetAccessor */: + case 168 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 159 /* Parameter */: + case 160 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -80749,40 +82782,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 203 /* TypeAssertionExpression */: - case 221 /* AsExpression */: + case 206 /* TypeAssertionExpression */: + case 224 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return visitCallExpression(node); - case 201 /* NewExpression */: + case 204 /* NewExpression */: return visitNewExpression(node); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 222 /* NonNullExpression */: + case 225 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 271 /* JsxSelfClosingElement */: + case 274 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 272 /* JsxOpeningElement */: + case 275 /* JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -81191,12 +83224,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -81349,7 +83382,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 162 /* PropertyDeclaration */ + ? member.kind === 163 /* PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -81473,10 +83506,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 164 /* MethodDeclaration */ - || kind === 166 /* GetAccessor */ - || kind === 167 /* SetAccessor */ - || kind === 162 /* PropertyDeclaration */; + return kind === 165 /* MethodDeclaration */ + || kind === 167 /* GetAccessor */ + || kind === 168 /* SetAccessor */ + || kind === 163 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -81486,7 +83519,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 164 /* MethodDeclaration */; + return node.kind === 165 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -81497,12 +83530,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return true; } return false; @@ -81519,15 +83552,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 162 /* PropertyDeclaration */: - case 159 /* Parameter */: + case 163 /* PropertyDeclaration */: + case 160 /* Parameter */: return serializeTypeNode(node.type); - case 167 /* SetAccessor */: - case 166 /* GetAccessor */: + case 168 /* SetAccessor */: + case 167 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 164 /* MethodDeclaration */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 165 /* MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -81564,7 +83597,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 166 /* GetAccessor */) { + if (container && node.kind === 167 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -81610,30 +83643,30 @@ var ts; } switch (node.kind) { case 113 /* VoidKeyword */: - case 149 /* UndefinedKeyword */: - case 140 /* NeverKeyword */: + case 150 /* UndefinedKeyword */: + case 141 /* NeverKeyword */: return factory.createVoidZero(); - case 185 /* ParenthesizedType */: + case 186 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 173 /* FunctionType */: - case 174 /* ConstructorType */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: return factory.createIdentifier("Function"); - case 177 /* ArrayType */: - case 178 /* TupleType */: + case 178 /* ArrayType */: + case 179 /* TupleType */: return factory.createIdentifier("Array"); - case 171 /* TypePredicate */: + case 172 /* TypePredicate */: case 131 /* BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 146 /* StringKeyword */: + case 147 /* StringKeyword */: return factory.createIdentifier("String"); - case 144 /* ObjectKeyword */: + case 145 /* ObjectKeyword */: return factory.createIdentifier("Object"); - case 190 /* LiteralType */: + case 191 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return factory.createIdentifier("Number"); case 9 /* BigIntLiteral */: @@ -81646,45 +83679,45 @@ var ts; default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 143 /* NumberKeyword */: + case 144 /* NumberKeyword */: return factory.createIdentifier("Number"); - case 154 /* BigIntKeyword */: + case 155 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 147 /* SymbolKeyword */: + case 148 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 172 /* TypeReference */: + case 173 /* TypeReference */: return serializeTypeReferenceNode(node); - case 182 /* IntersectionType */: - case 181 /* UnionType */: + case 183 /* IntersectionType */: + case 182 /* UnionType */: return serializeTypeList(node.types); - case 183 /* ConditionalType */: + case 184 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 187 /* TypeOperator */: - if (node.operator === 141 /* ReadonlyKeyword */) { + case 188 /* TypeOperator */: + if (node.operator === 142 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 175 /* TypeQuery */: - case 188 /* IndexedAccessType */: - case 189 /* MappedType */: - case 176 /* TypeLiteral */: + case 176 /* TypeQuery */: + case 189 /* IndexedAccessType */: + case 190 /* MappedType */: + case 177 /* TypeLiteral */: case 128 /* AnyKeyword */: - case 151 /* UnknownKeyword */: - case 186 /* ThisType */: - case 192 /* ImportType */: + case 152 /* UnknownKeyword */: + case 187 /* ThisType */: + case 195 /* ImportType */: break; // handle JSDoc types from an invalid parse - case 299 /* JSDocAllType */: - case 300 /* JSDocUnknownType */: - case 304 /* JSDocFunctionType */: - case 305 /* JSDocVariadicType */: - case 306 /* JSDocNamepathType */: + case 303 /* JSDocAllType */: + case 304 /* JSDocUnknownType */: + case 308 /* JSDocFunctionType */: + case 309 /* JSDocVariadicType */: + case 310 /* JSDocNamepathType */: break; - case 301 /* JSDocNullableType */: - case 302 /* JSDocNonNullableType */: - case 303 /* JSDocOptionalType */: + case 305 /* JSDocNullableType */: + case 306 /* JSDocNonNullableType */: + case 307 /* JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -81695,15 +83728,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { - var typeNode = types_21[_i]; - while (typeNode.kind === 185 /* ParenthesizedType */) { + for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { + var typeNode = types_22[_i]; + while (typeNode.kind === 186 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 140 /* NeverKeyword */) { + if (typeNode.kind === 141 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 190 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 149 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -81813,7 +83846,7 @@ var ts; name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -82387,12 +84420,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 294 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 297 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 252 /* EnumDeclaration */) { + if (node.kind === 255 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -82517,7 +84550,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 254 /* ModuleBlock */) { + if (node.body.kind === 257 /* ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -82564,13 +84597,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 254 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 257 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 253 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 256 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -82620,7 +84653,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 260 /* NamespaceImport */) { + if (node.kind === 263 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -82869,16 +84902,16 @@ var ts; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. context.enableSubstitution(78 /* Identifier */); - context.enableSubstitution(286 /* ShorthandPropertyAssignment */); + context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(253 /* ModuleDeclaration */); + context.enableEmitNotification(256 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 253 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 256 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 252 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 255 /* EnumDeclaration */; } /** * Hook for node emit. @@ -82939,9 +84972,9 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return substituteExpressionIdentifier(node); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -82979,9 +85012,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 294 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 253 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 252 /* EnumDeclaration */); + if (container && container.kind !== 297 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 256 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 255 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -83081,40 +85114,40 @@ var ts; if (!(node.transformFlags & 4194304 /* ContainsClassFields */)) return node; switch (node.kind) { - case 218 /* ClassExpression */: - case 249 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 252 /* ClassDeclaration */: return visitClassLike(node); - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return visitVariableStatement(node); - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return visitPrefixUnaryExpression(node); - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: return visitPostfixUnaryExpression(node, /*valueIsDiscarded*/ false); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return visitCallExpression(node); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return visitBinaryExpression(node); case 79 /* PrivateIdentifier */: return visitPrivateIdentifier(node); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return visitExpressionStatement(node); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return visitForStatement(node); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); } return ts.visitEachChild(node, visitor, context); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 197 /* ObjectLiteralExpression */: - case 196 /* ArrayLiteralExpression */: + case 200 /* ObjectLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -83137,20 +85170,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 165 /* Constructor */: + case 166 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 164 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 165 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 226 /* SemicolonClassElement */: + case 229 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -83902,31 +85935,31 @@ var ts; case 129 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 210 /* AwaitExpression */: + case 213 /* AwaitExpression */: return visitAwaitExpression(node); - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 165 /* Constructor */: - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 166 /* Constructor */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -83935,27 +85968,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 227 /* Block */: - case 241 /* SwitchStatement */: - case 255 /* CaseBlock */: - case 281 /* CaseClause */: - case 282 /* DefaultClause */: - case 244 /* TryStatement */: - case 232 /* DoStatement */: - case 233 /* WhileStatement */: - case 231 /* IfStatement */: - case 240 /* WithStatement */: - case 242 /* LabeledStatement */: + case 230 /* Block */: + case 244 /* SwitchStatement */: + case 258 /* CaseBlock */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: + case 247 /* TryStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: + case 234 /* IfStatement */: + case 243 /* WithStatement */: + case 245 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -84160,7 +86193,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 206 /* ArrowFunction */; + var isArrowFunction = node.kind === 209 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -84251,17 +86284,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(200 /* CallExpression */); - context.enableSubstitution(198 /* PropertyAccessExpression */); - context.enableSubstitution(199 /* ElementAccessExpression */); + context.enableSubstitution(203 /* CallExpression */); + context.enableSubstitution(201 /* PropertyAccessExpression */); + context.enableSubstitution(202 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(249 /* ClassDeclaration */); - context.enableEmitNotification(164 /* MethodDeclaration */); - context.enableEmitNotification(166 /* GetAccessor */); - context.enableEmitNotification(167 /* SetAccessor */); - context.enableEmitNotification(165 /* Constructor */); + context.enableEmitNotification(252 /* ClassDeclaration */); + context.enableEmitNotification(165 /* MethodDeclaration */); + context.enableEmitNotification(167 /* GetAccessor */); + context.enableEmitNotification(168 /* SetAccessor */); + context.enableEmitNotification(166 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(229 /* VariableStatement */); + context.enableEmitNotification(232 /* VariableStatement */); } } /** @@ -84309,11 +86342,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -84345,11 +86378,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 249 /* ClassDeclaration */ - || kind === 165 /* Constructor */ - || kind === 164 /* MethodDeclaration */ - || kind === 166 /* GetAccessor */ - || kind === 167 /* SetAccessor */; + return kind === 252 /* ClassDeclaration */ + || kind === 166 /* Constructor */ + || kind === 165 /* MethodDeclaration */ + || kind === 167 /* GetAccessor */ + || kind === 168 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -84500,10 +86533,10 @@ var ts; return visited; } function visitor(node) { - return visitorWorker(node, /*noDestructuringValue*/ false); + return visitorWorker(node, /*expressionResultIsUnused*/ false); } - function visitorNoDestructuringValue(node) { - return visitorWorker(node, /*noDestructuringValue*/ true); + function visitorWithUnusedExpressionResult(node) { + return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { if (node.kind === 129 /* AsyncKeyword */) { @@ -84523,73 +86556,79 @@ var ts; function visitDefault(node) { return ts.visitEachChild(node, visitor, context); } - function visitorWorker(node, noDestructuringValue) { + /** + * @param expressionResultIsUnused Indicates the result of an expression is unused by the parent node (i.e., the left side of a comma or the + * expression of an `ExpressionStatement`). + */ + function visitorWorker(node, expressionResultIsUnused) { if ((node.transformFlags & 32 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 210 /* AwaitExpression */: + case 213 /* AwaitExpression */: return visitAwaitExpression(node); - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: return visitYieldExpression(node); - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: return visitReturnStatement(node); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return visitLabeledStatement(node); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 213 /* BinaryExpression */: - return visitBinaryExpression(node, noDestructuringValue); - case 284 /* CatchClause */: + case 216 /* BinaryExpression */: + return visitBinaryExpression(node, expressionResultIsUnused); + case 337 /* CommaListExpression */: + return visitCommaListExpression(node, expressionResultIsUnused); + case 287 /* CatchClause */: return visitCatchClause(node); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return visitVariableStatement(node); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 232 /* DoStatement */: - case 233 /* WhileStatement */: - case 235 /* ForInStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: + case 238 /* ForInStatement */: return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 209 /* VoidExpression */: + case 212 /* VoidExpression */: return visitVoidExpression(node); - case 165 /* Constructor */: + case 166 /* Constructor */: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 166 /* GetAccessor */: + case 167 /* GetAccessor */: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 167 /* SetAccessor */: + case 168 /* SetAccessor */: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 159 /* Parameter */: + case 160 /* Parameter */: return visitParameter(node); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return visitExpressionStatement(node); - case 204 /* ParenthesizedExpression */: - return visitParenthesizedExpression(node, noDestructuringValue); - case 202 /* TaggedTemplateExpression */: + case 207 /* ParenthesizedExpression */: + return visitParenthesizedExpression(node, expressionResultIsUnused); + case 205 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); @@ -84625,7 +86664,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 236 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 239 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -84637,7 +86676,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 287 /* SpreadAssignment */) { + if (e.kind === 290 /* SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -84646,7 +86685,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 285 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 288 /* PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -84680,7 +86719,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 197 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 200 /* ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -84697,10 +86736,14 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitExpressionStatement(node) { - return ts.visitEachChild(node, visitorNoDestructuringValue, context); + return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); } - function visitParenthesizedExpression(node, noDestructuringValue) { - return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context); + /** + * @param expressionResultIsUnused Indicates the result of an expression is unused by the parent node (i.e., the left side of a comma or the + * expression of an `ExpressionStatement`). + */ + function visitParenthesizedExpression(node, expressionResultIsUnused) { + return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? @@ -84722,16 +86765,38 @@ var ts; * Visits a BinaryExpression that contains a destructuring assignment. * * @param node A BinaryExpression node. + * @param expressionResultIsUnused Indicates the result of an expression is unused by the parent node (i.e., the left side of a comma or the + * expression of an `ExpressionStatement`). */ - function visitBinaryExpression(node, noDestructuringValue) { + function visitBinaryExpression(node, expressionResultIsUnused) { if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !noDestructuringValue); + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { - return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), node.operatorToken, ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); + if (node.operatorToken.kind === 27 /* CommaToken */) { + return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); } + /** + * @param expressionResultIsUnused Indicates the result of an expression is unused by the parent node (i.e., the left side of a comma or the + * expression of an `ExpressionStatement`). + */ + function visitCommaListExpression(node, expressionResultIsUnused) { + if (expressionResultIsUnused) { + return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); + } + var result; + for (var i = 0; i < node.elements.length; i++) { + var element = node.elements[i]; + var visited = ts.visitNode(element, i < node.elements.length - 1 ? visitorWithUnusedExpressionResult : visitor, ts.isExpression); + if (result || visited !== element) { + result || (result = node.elements.slice(0, i)); + result.push(visited); + } + } + var elements = result ? ts.setTextRange(factory.createNodeArray(result), node.elements) : node.elements; + return factory.updateCommaListExpression(node, elements); + } function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && @@ -84783,10 +86848,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitForStatement(node) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorNoDestructuringValue, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement)); + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement)); } function visitVoidExpression(node) { - return ts.visitEachChild(node, visitorNoDestructuringValue, context); + return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); } /** * Visits a ForOfStatement and converts it into a ES2015-compatible ForOfStatement. @@ -85067,17 +87132,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(200 /* CallExpression */); - context.enableSubstitution(198 /* PropertyAccessExpression */); - context.enableSubstitution(199 /* ElementAccessExpression */); + context.enableSubstitution(203 /* CallExpression */); + context.enableSubstitution(201 /* PropertyAccessExpression */); + context.enableSubstitution(202 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(249 /* ClassDeclaration */); - context.enableEmitNotification(164 /* MethodDeclaration */); - context.enableEmitNotification(166 /* GetAccessor */); - context.enableEmitNotification(167 /* SetAccessor */); - context.enableEmitNotification(165 /* Constructor */); + context.enableEmitNotification(252 /* ClassDeclaration */); + context.enableEmitNotification(165 /* MethodDeclaration */); + context.enableEmitNotification(167 /* GetAccessor */); + context.enableEmitNotification(168 /* SetAccessor */); + context.enableEmitNotification(166 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(229 /* VariableStatement */); + context.enableEmitNotification(232 /* VariableStatement */); } } /** @@ -85125,11 +87190,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -85161,11 +87226,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 249 /* ClassDeclaration */ - || kind === 165 /* Constructor */ - || kind === 164 /* MethodDeclaration */ - || kind === 166 /* GetAccessor */ - || kind === 167 /* SetAccessor */; + return kind === 252 /* ClassDeclaration */ + || kind === 166 /* Constructor */ + || kind === 165 /* MethodDeclaration */ + || kind === 167 /* GetAccessor */ + || kind === 168 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -85197,7 +87262,7 @@ var ts; return node; } switch (node.kind) { - case 284 /* CatchClause */: + case 287 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -85229,21 +87294,21 @@ var ts; return node; } switch (node.kind) { - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: - case 200 /* CallExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: + case 203 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 207 /* DeleteExpression */: + case 210 /* DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -85286,7 +87351,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 198 /* PropertyAccessExpression */ + expression = node.kind === 201 /* PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -85300,10 +87365,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 204 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 200 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 207 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 203 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -85323,8 +87388,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -85335,11 +87400,11 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 198 /* PropertyAccessExpression */ + rightExpression = segment.kind === 201 /* PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 200 /* CallExpression */: + case 203 /* CallExpression */: if (i === 0 && leftThisArg) { rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } @@ -85396,7 +87461,7 @@ var ts; return node; } switch (node.kind) { - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -85441,7 +87506,49 @@ var ts; var factory = context.factory, emitHelpers = context.getEmitHelperFactory; var compilerOptions = context.getCompilerOptions(); var currentSourceFile; + var currentFileState; return ts.chainBundle(context, transformSourceFile); + function getCurrentFileNameExpression() { + if (currentFileState.filenameDeclaration) { + return currentFileState.filenameDeclaration.name; + } + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + currentFileState.filenameDeclaration = declaration; + return currentFileState.filenameDeclaration.name; + } + function getJsxFactoryCalleePrimitive(childrenLength) { + return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : childrenLength > 1 ? "jsxs" : "jsx"; + } + function getJsxFactoryCallee(childrenLength) { + var type = getJsxFactoryCalleePrimitive(childrenLength); + return getImplicitImportForName(type); + } + function getImplicitJsxFragmentReference() { + return getImplicitImportForName("Fragment"); + } + function getImplicitImportForName(name) { + var _a, _b; + var importSource = name === "createElement" + ? currentFileState.importSpecifier + : ts.getJSXRuntimeImport(currentFileState.importSpecifier, compilerOptions); + var existing = (_b = (_a = currentFileState.utilizedImplicitRuntimeImports) === null || _a === void 0 ? void 0 : _a.get(importSource)) === null || _b === void 0 ? void 0 : _b.get(name); + if (existing) { + return existing.name; + } + if (!currentFileState.utilizedImplicitRuntimeImports) { + currentFileState.utilizedImplicitRuntimeImports = ts.createMap(); + } + var specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource); + if (!specifierSourceImports) { + specifierSourceImports = ts.createMap(); + currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); + } + var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var specifier = factory.createImportSpecifier(factory.createIdentifier(name), generatedName); + generatedName.generatedImportReference = specifier; + specifierSourceImports.set(name, specifier); + return generatedName; + } /** * Transform JSX-specific syntax in a SourceFile. * @@ -85452,8 +87559,42 @@ var ts; return node; } currentSourceFile = node; + currentFileState = {}; + currentFileState.importSpecifier = ts.getJSXImplicitImportBase(compilerOptions, node); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); + var statements = visited.statements; + if (currentFileState.filenameDeclaration) { + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + } + if (currentFileState.utilizedImplicitRuntimeImports) { + for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { + var _b = _a[_i], importSource = _b[0], importSpecifiersMap = _b[1]; + if (ts.isExternalModule(node)) { + // Add `import` statement + var importStatement = factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause(/*typeOnly*/ false, /*name*/ undefined, factory.createNamedImports(ts.arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource)); + ts.setParentRecursive(importStatement, /*incremental*/ false); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), importStatement); + } + else if (ts.isExternalOrCommonJsModule(node)) { + // Add `require` statement + var requireStatement = factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([ + factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), + /*exclaimationToken*/ undefined, + /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) + ], 2 /* Const */)); + ts.setParentRecursive(requireStatement, /*incremental*/ false); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); + } + else { + // Do nothing (script file) - consider an error in the checker? + } + } + } + if (statements !== visited.statements) { + visited = factory.updateSourceFile(visited, statements); + } + currentFileState = undefined; return visited; } function visitor(node) { @@ -85466,13 +87607,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 270 /* JsxElement */: + case 273 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 271 /* JsxSelfClosingElement */: + case 274 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 274 /* JsxFragment */: + case 277 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 280 /* JsxExpression */: + case 283 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -85482,28 +87623,122 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 280 /* JsxExpression */: + case 283 /* JsxExpression */: return visitJsxExpression(node); - case 270 /* JsxElement */: + case 273 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 271 /* JsxSelfClosingElement */: + case 274 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 274 /* JsxFragment */: + case 277 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); } } + /** + * The react jsx/jsxs transform falls back to `createElement` when an explicit `key` argument comes after a spread + */ + function hasKeyAfterPropsSpread(node) { + var spread = false; + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { + var elem = _a[_i]; + if (ts.isJsxSpreadAttribute(elem)) { + spread = true; + } + else if (spread && ts.isJsxAttribute(elem) && elem.name.escapedText === "key") { + return true; + } + } + return false; + } + function shouldUseCreateElement(node) { + return currentFileState.importSpecifier === undefined || hasKeyAfterPropsSpread(node); + } function visitJsxElement(node, isChild) { - return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, /*location*/ node); + var tagTransform = shouldUseCreateElement(node.openingElement) ? visitJsxOpeningLikeElementCreateElement : visitJsxOpeningLikeElementJSX; + return tagTransform(node.openingElement, node.children, isChild, /*location*/ node); } function visitJsxSelfClosingElement(node, isChild) { - return visitJsxOpeningLikeElement(node, /*children*/ undefined, isChild, /*location*/ node); + var tagTransform = shouldUseCreateElement(node) ? visitJsxOpeningLikeElementCreateElement : visitJsxOpeningLikeElementJSX; + return tagTransform(node, /*children*/ undefined, isChild, /*location*/ node); } function visitJsxFragment(node, isChild) { - return visitJsxOpeningFragment(node.openingFragment, node.children, isChild, /*location*/ node); + var tagTransform = currentFileState.importSpecifier === undefined ? visitJsxOpeningFragmentCreateElement : visitJsxOpeningFragmentJSX; + return tagTransform(node.openingFragment, node.children, isChild, /*location*/ node); + } + function convertJsxChildrenToChildrenPropObject(children) { + var nonWhitespaceChildren = ts.getSemanticJsxChildren(children); + if (ts.length(nonWhitespaceChildren) === 1) { + var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]); + return result_13 && factory.createObjectLiteralExpression([ + factory.createPropertyAssignment("children", result_13) + ]); + } + var result = ts.mapDefined(children, transformJsxChildToExpression); + return !result.length ? undefined : factory.createObjectLiteralExpression([ + factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) + ]); + } + function visitJsxOpeningLikeElementJSX(node, children, isChild, location) { + var tagName = getTagName(node); + var objectProperties; + var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; }); + var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties; + var segments = []; + if (attrs.length) { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument.factory.createObjectLiteral + segments.unshift(factory.createObjectLiteralExpression()); + } + } + if (children && children.length) { + var result = convertJsxChildrenToChildrenPropObject(children); + if (result) { + segments.push(result); + } + } + if (segments.length === 0) { + objectProperties = factory.createObjectLiteralExpression([]); + // When there are no attributes, React wants {} + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to the __assign helper. + objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments); + } + return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location); + } + function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) { + var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)]; + if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + var originalFile = ts.getOriginalNode(currentSourceFile); + if (originalFile && ts.isSourceFile(originalFile)) { + // isStaticChildren development flag + args.push(childrenLength > 1 ? factory.createTrue() : factory.createFalse()); + // __source development flag + var lineCol = ts.getLineAndCharacterOfPosition(originalFile, location.pos); + args.push(factory.createObjectLiteralExpression([ + factory.createPropertyAssignment("fileName", getCurrentFileNameExpression()), + factory.createPropertyAssignment("lineNumber", factory.createNumericLiteral(lineCol.line + 1)), + factory.createPropertyAssignment("columnNumber", factory.createNumericLiteral(lineCol.character + 1)) + ])); + // __self development flag + args.push(factory.createThis()); + } + } + var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(childrenLength), /*typeArguments*/ undefined, args), location); + if (isChild) { + ts.startOnNewLine(element); + } + return element; } - function visitJsxOpeningLikeElement(node, children, isChild, location) { + function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; var attrs = node.attributes.properties; @@ -85529,14 +87764,28 @@ var ts; objectProperties = emitHelpers().createAssignHelper(segments); } } - var element = ts.createExpressionForJsxElement(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 - tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); + var callee = currentFileState.importSpecifier === undefined + ? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 + node) + : getImplicitImportForName("createElement"); + var element = ts.createExpressionForJsxElement(factory, callee, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), location); if (isChild) { ts.startOnNewLine(element); } return element; } - function visitJsxOpeningFragment(node, children, isChild, location) { + function visitJsxOpeningFragmentJSX(_node, children, isChild, location) { + var childrenProps; + if (children && children.length) { + var result = convertJsxChildrenToChildrenPropObject(children); + if (result) { + childrenProps = result; + } + } + return visitJsxOpeningLikeElementOrFragmentJSX(getImplicitJsxFragmentReference(), childrenProps || factory.createObjectLiteralExpression([]), + /*keyAttr*/ undefined, ts.length(ts.getSemanticJsxChildren(children)), isChild, location); + } + function visitJsxOpeningFragmentCreateElement(node, children, isChild, location) { var element = ts.createExpressionForJsxFragment(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), context.getEmitResolver().getJsxFragmentFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { @@ -85563,7 +87812,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 280 /* JsxExpression */) { + else if (node.kind === 283 /* JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -85657,7 +87906,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 270 /* JsxElement */) { + if (node.kind === 273 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -85963,7 +88212,7 @@ var ts; return node; } switch (node.kind) { - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -86176,7 +88425,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 239 /* ReturnStatement */ + && node.kind === 242 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { @@ -86202,12 +88451,10 @@ var ts; || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } function visitor(node) { - if (shouldVisitNode(node)) { - return visitJavaScript(node); - } - else { - return node; - } + return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; + } + function visitorWithUnusedExpressionResult(node) { + return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ true) : node; } function callExpressionVisitor(node) { if (node.kind === 105 /* SuperKeyword */) { @@ -86215,68 +88462,70 @@ var ts; } return visitor(node); } - function visitJavaScript(node) { + function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { case 123 /* StaticKeyword */: return undefined; // elide static keyword - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: return visitClassDeclaration(node); - case 218 /* ClassExpression */: + case 221 /* ClassExpression */: return visitClassExpression(node); - case 159 /* Parameter */: + case 160 /* Parameter */: return visitParameter(node); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return visitArrowFunction(node); - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: return visitFunctionExpression(node); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return visitVariableDeclaration(node); case 78 /* Identifier */: return visitIdentifier(node); - case 247 /* VariableDeclarationList */: + case 250 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: return visitSwitchStatement(node); - case 255 /* CaseBlock */: + case 258 /* CaseBlock */: return visitCaseBlock(node); - case 227 /* Block */: + case 230 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 238 /* BreakStatement */: - case 237 /* ContinueStatement */: + case 241 /* BreakStatement */: + case 240 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* DoStatement */: - case 233 /* WhileStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return visitExpressionStatement(node); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return visitCatchClause(node); - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return visitCallExpression(node); - case 201 /* NewExpression */: + case 204 /* NewExpression */: return visitNewExpression(node); - case 204 /* ParenthesizedExpression */: - return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 213 /* BinaryExpression */: - return visitBinaryExpression(node, /*needsDestructuringValue*/ true); + case 207 /* ParenthesizedExpression */: + return visitParenthesizedExpression(node, expressionResultIsUnused); + case 216 /* BinaryExpression */: + return visitBinaryExpression(node, expressionResultIsUnused); + case 337 /* CommaListExpression */: + return visitCommaListExpression(node, expressionResultIsUnused); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: @@ -86286,29 +88535,31 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 215 /* TemplateExpression */: + case 218 /* TemplateExpression */: return visitTemplateExpression(node); - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: return visitYieldExpression(node); - case 217 /* SpreadElement */: + case 220 /* SpreadElement */: return visitSpreadElement(node); case 105 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 107 /* ThisKeyword */: return visitThisKeyword(node); - case 223 /* MetaProperty */: + case 226 /* MetaProperty */: return visitMetaProperty(node); - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return visitAccessorDeclaration(node); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return visitVariableStatement(node); - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: return visitReturnStatement(node); + case 212 /* VoidExpression */: + return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } @@ -86379,6 +88630,9 @@ var ts; } return node; } + function visitVoidExpression(node) { + return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); + } function visitIdentifier(node) { if (!convertedLoopState) { return node; @@ -86394,14 +88648,14 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 238 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 241 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 238 /* BreakStatement */) { + if (node.kind === 241 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -86412,7 +88666,7 @@ var ts; } } else { - if (node.kind === 238 /* BreakStatement */) { + if (node.kind === 241 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -86564,16 +88818,17 @@ var ts; */ function transformClassBody(node, extendsClauseElement) { var statements = []; + var name = factory.getInternalName(node); + var constructorLikeName = ts.isIdentifierANonContextualKeyword(name) ? factory.getGeneratedNameForNode(name) : name; startLexicalEnvironment(); addExtendsHelperIfNeeded(statements, node, extendsClauseElement); - addConstructor(statements, node, extendsClauseElement); + addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); - var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. - var outer = factory.createPartiallyEmittedExpression(localName); + var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); ts.setEmitFlags(outer, 1536 /* NoComments */); var statement = factory.createReturnStatement(outer); @@ -86605,7 +88860,7 @@ var ts; * @param node The ClassExpression or ClassDeclaration node. * @param extendsClauseElement The expression for the class `extends` clause. */ - function addConstructor(statements, node, extendsClauseElement) { + function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); @@ -86614,7 +88869,7 @@ var ts; var constructorFunction = factory.createFunctionDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*asteriskToken*/ undefined, factory.getInternalName(node), + /*asteriskToken*/ undefined, name, /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); @@ -86809,11 +89064,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 239 /* ReturnStatement */) { + if (statement.kind === 242 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 231 /* IfStatement */) { + else if (statement.kind === 234 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -86821,7 +89076,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 227 /* Block */) { + else if (statement.kind === 230 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -87023,7 +89278,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 206 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 209 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -87045,22 +89300,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return statements; - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 165 /* Constructor */: + case 166 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 101 /* InstanceOfKeyword */, factory.getLocalName(node))), @@ -87095,20 +89350,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 226 /* SemicolonClassElement */: + case 229 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 165 /* Constructor */: + case 166 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -87311,7 +89566,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 248 /* FunctionDeclaration */ || node.kind === 205 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -87357,7 +89612,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 206 /* ArrowFunction */); + ts.Debug.assert(node.kind === 209 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -87423,51 +89678,55 @@ var ts; * @param node An ExpressionStatement node. */ function visitExpressionStatement(node) { - // If we are here it is most likely because our expression is a destructuring assignment. - switch (node.expression.kind) { - case 204 /* ParenthesizedExpression */: - return factory.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 213 /* BinaryExpression */: - return factory.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); - } - return ts.visitEachChild(node, visitor, context); + return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); } /** * Visits a ParenthesizedExpression that may contain a destructuring assignment. * * @param node A ParenthesizedExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. - */ - function visitParenthesizedExpression(node, needsDestructuringValue) { - // If we are here it is most likely because our expression is a destructuring assignment. - if (!needsDestructuringValue) { - // By default we always emit the RHS at the end of a flattened destructuring - // expression. If we are in a state where we do not need the destructuring value, - // we pass that information along to the children that care about it. - switch (node.expression.kind) { - case 204 /* ParenthesizedExpression */: - return factory.updateParenthesizedExpression(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 213 /* BinaryExpression */: - return factory.updateParenthesizedExpression(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); - } - } - return ts.visitEachChild(node, visitor, context); + * @param expressionResultIsUnused Indicates the result of an expression is unused by the parent node (i.e., the left side of a comma or the + * expression of an `ExpressionStatement`). + */ + function visitParenthesizedExpression(node, expressionResultIsUnused) { + return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } /** * Visits a BinaryExpression that contains a destructuring assignment. * * @param node A BinaryExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. + * @param expressionResultIsUnused Indicates the result of an expression is unused by the parent node (i.e., the left side of a comma or the + * expression of an `ExpressionStatement`). */ - function visitBinaryExpression(node, needsDestructuringValue) { + function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, needsDestructuringValue); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + } + if (node.operatorToken.kind === 27 /* CommaToken */) { + return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); } + /** + * @param expressionResultIsUnused Indicates the result of an expression is unused by the parent node (i.e., the left side of a comma or the + * expression of an `ExpressionStatement`). + */ + function visitCommaListExpression(node, expressionResultIsUnused) { + if (expressionResultIsUnused) { + return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); + } + var result; + for (var i = 0; i < node.elements.length; i++) { + var element = node.elements[i]; + var visited = ts.visitNode(element, i < node.elements.length - 1 ? visitorWithUnusedExpressionResult : visitor, ts.isExpression); + if (result || visited !== element) { + result || (result = node.elements.slice(0, i)); + result.push(visited); + } + } + var elements = result ? ts.setTextRange(factory.createNodeArray(result), node.elements) : node.elements; + return factory.updateCommaListExpression(node, elements); + } function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer @@ -87660,14 +89919,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 232 /* DoStatement */: - case 233 /* WhileStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -87683,6 +89942,9 @@ var ts; function visitForStatement(node, outermostLabeledStatement) { return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); } + function visitEachChildOfForStatement(node) { + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + } function visitForInStatement(node, outermostLabeledStatement) { return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } @@ -87725,7 +89987,7 @@ var ts; // evaluated on every iteration. var assignment = factory.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { - statements.push(factory.createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(factory.createExpressionStatement(visitBinaryExpression(assignment, /*expressionResultIsUnused*/ true))); } else { ts.setTextRangeEnd(assignment, initializer.end); @@ -87850,7 +90112,7 @@ var ts; var property = properties[i]; if ((property.transformFlags & 262144 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 157 /* ComputedPropertyName */)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158 /* ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -87926,7 +90188,7 @@ var ts; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) - : factory.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); + : factory.restoreEnclosingLabel(ts.isForStatement(node) ? visitEachChildOfForStatement(node) : ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -87966,18 +90228,18 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 234 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 235 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 236 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 232 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 233 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 237 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 238 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 239 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 235 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 236 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } function convertForStatement(node, initializerFunction, convertedLoopBody) { var shouldConvertCondition = node.condition && shouldConvertPartOfIterationStatement(node.condition); var shouldConvertIncrementor = shouldConvertCondition || node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor); - return factory.updateForStatement(node, ts.visitNode(initializerFunction ? initializerFunction.part : node.initializer, visitor, ts.isForInitializer), ts.visitNode(shouldConvertCondition ? undefined : node.condition, visitor, ts.isExpression), ts.visitNode(shouldConvertIncrementor ? undefined : node.incrementor, visitor, ts.isExpression), convertedLoopBody); + return factory.updateForStatement(node, ts.visitNode(initializerFunction ? initializerFunction.part : node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(shouldConvertCondition ? undefined : node.condition, visitor, ts.isExpression), ts.visitNode(shouldConvertIncrementor ? undefined : node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), convertedLoopBody); } function convertForOfStatement(node, convertedLoopBody) { return factory.updateForOfStatement(node, @@ -87995,11 +90257,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 247 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 250 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -88407,20 +90669,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -88527,7 +90789,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 166 /* GetAccessor */) { + if (node.kind === 167 /* GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -89019,13 +91281,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(107 /* ThisKeyword */); - context.enableEmitNotification(165 /* Constructor */); - context.enableEmitNotification(164 /* MethodDeclaration */); - context.enableEmitNotification(166 /* GetAccessor */); - context.enableEmitNotification(167 /* SetAccessor */); - context.enableEmitNotification(206 /* ArrowFunction */); - context.enableEmitNotification(205 /* FunctionExpression */); - context.enableEmitNotification(248 /* FunctionDeclaration */); + context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(165 /* MethodDeclaration */); + context.enableEmitNotification(167 /* GetAccessor */); + context.enableEmitNotification(168 /* SetAccessor */); + context.enableEmitNotification(209 /* ArrowFunction */); + context.enableEmitNotification(208 /* FunctionExpression */); + context.enableEmitNotification(251 /* FunctionDeclaration */); } } /** @@ -89066,10 +91328,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 195 /* BindingElement */: - case 249 /* ClassDeclaration */: - case 252 /* EnumDeclaration */: - case 246 /* VariableDeclaration */: + case 198 /* BindingElement */: + case 252 /* ClassDeclaration */: + case 255 /* EnumDeclaration */: + case 249 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -89151,11 +91413,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 230 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 200 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -89163,7 +91425,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 217 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -89189,15 +91451,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(272 /* JsxOpeningElement */); - context.enableEmitNotification(273 /* JsxClosingElement */); - context.enableEmitNotification(271 /* JsxSelfClosingElement */); + context.enableEmitNotification(275 /* JsxOpeningElement */); + context.enableEmitNotification(276 /* JsxClosingElement */); + context.enableEmitNotification(274 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(198 /* PropertyAccessExpression */); - context.enableSubstitution(285 /* PropertyAssignment */); + context.enableSubstitution(201 /* PropertyAccessExpression */); + context.enableSubstitution(288 /* PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -89216,9 +91478,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 272 /* JsxOpeningElement */: - case 273 /* JsxClosingElement */: - case 271 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: + case 276 /* JsxClosingElement */: + case 274 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -89553,13 +91815,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 232 /* DoStatement */: + case 235 /* DoStatement */: return visitDoStatement(node); - case 233 /* WhileStatement */: + case 236 /* WhileStatement */: return visitWhileStatement(node); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: return visitSwitchStatement(node); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -89572,24 +91834,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: return visitFunctionExpression(node); - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return visitAccessorDeclaration(node); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return visitForStatement(node); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return visitForInStatement(node); - case 238 /* BreakStatement */: + case 241 /* BreakStatement */: return visitBreakStatement(node); - case 237 /* ContinueStatement */: + case 240 /* ContinueStatement */: return visitContinueStatement(node); - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 262144 /* ContainsYield */) { @@ -89610,23 +91872,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return visitBinaryExpression(node); - case 332 /* CommaListExpression */: + case 337 /* CommaListExpression */: return visitCommaListExpression(node); - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return visitConditionalExpression(node); - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: return visitYieldExpression(node); - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return visitCallExpression(node); - case 201 /* NewExpression */: + case 204 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89639,9 +91901,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -89849,7 +92111,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -89861,7 +92123,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -90255,35 +92517,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 227 /* Block */: + case 230 /* Block */: return transformAndEmitBlock(node); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 231 /* IfStatement */: + case 234 /* IfStatement */: return transformAndEmitIfStatement(node); - case 232 /* DoStatement */: + case 235 /* DoStatement */: return transformAndEmitDoStatement(node); - case 233 /* WhileStatement */: + case 236 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return transformAndEmitForStatement(node); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 237 /* ContinueStatement */: + case 240 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 238 /* BreakStatement */: + case 241 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 240 /* WithStatement */: + case 243 /* WithStatement */: return transformAndEmitWithStatement(node); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 243 /* ThrowStatement */: + case 246 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 244 /* TryStatement */: + case 247 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -90713,7 +92975,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 282 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 285 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -90726,7 +92988,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 281 /* CaseClause */) { + if (clause.kind === 284 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -91887,11 +94149,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(213 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(211 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(212 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(286 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(294 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -91942,7 +94204,10 @@ var ts; ts.append(statements, createUnderscoreUnderscoreESModule()); } if (ts.length(currentModuleInfo.exportedNames)) { - ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); }, factory.createVoidZero()))); + var chunkSize = 50; + for (var i = 0; i < currentModuleInfo.exportedNames.length; i += chunkSize) { + ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames.slice(i, i + chunkSize), function (prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); }, factory.createVoidZero()))); + } } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); @@ -92216,23 +94481,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return visitImportDeclaration(node); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return visitExportDeclaration(node); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return visitExportAssignment(node); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return visitVariableStatement(node); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: return visitClassDeclaration(node); - case 333 /* MergeDeclarationMarker */: + case 338 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 334 /* EndOfDeclarationMarker */: + case 339 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -92259,24 +94524,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 287 /* SpreadAssignment */: + case 290 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -92611,9 +94876,11 @@ var ts; else if (node.exportClause) { var statements = []; // export * as ns from "mod"; + // export * as default from "mod"; statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.cloneNode(node.exportClause.name), getHelperExpressionForExport(node, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : - factory.createIdentifier(ts.idText(node.exportClause.name))))), node), node)); + ts.isExportNamespaceAsDefaultDeclaration(node) ? generatedName : + factory.createIdentifier(ts.idText(node.exportClause.name))))), node), node)); return ts.singleOrMany(statements); } else { @@ -92706,6 +94973,7 @@ var ts; var expressions; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { var modifiers = void 0; + var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -92716,14 +94984,28 @@ var ts; variables = ts.append(variables, variable); } else if (variable.initializer) { - expressions = ts.append(expressions, transformInitializedVariable(variable)); + if (!ts.isBindingPattern(variable.name) && (ts.isArrowFunction(variable.initializer) || ts.isFunctionExpression(variable.initializer) || ts.isClassExpression(variable.initializer))) { + var expression = factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), + /*location*/ variable.name), factory.createIdentifier(ts.getTextOfIdentifierOrLiteral(variable.name))); + var updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts.visitNode(variable.initializer, moduleExpressionElementVisitor)); + variables = ts.append(variables, updatedVariable); + expressions = ts.append(expressions, expression); + removeCommentsOnExpressions = true; + } + else { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } } } if (variables) { statements = ts.append(statements, factory.updateVariableStatement(node, modifiers, factory.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node), node)); + var statement = ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node), node); + if (removeCommentsOnExpressions) { + ts.removeAllComments(statement); + } + statements = ts.append(statements, statement); } } else { @@ -92784,7 +95066,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 229 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -92839,10 +95121,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 261 /* NamedImports */: + case 264 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -93055,7 +95337,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 294 /* SourceFile */) { + if (node.kind === 297 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -93119,10 +95401,10 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return substituteExpressionIdentifier(node); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return substituteBinaryExpression(node); - case 212 /* PostfixUnaryExpression */: - case 211 /* PrefixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -93141,9 +95423,9 @@ var ts; } return node; } - if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 294 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -93218,7 +95500,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 212 /* PostfixUnaryExpression */ + var expression = node.kind === 215 /* PostfixUnaryExpression */ ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), factory.createNumericLiteral(1)), /*location*/ node) : node; @@ -93270,12 +95552,12 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(286 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(213 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(211 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(212 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(223 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(294 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(226 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -93499,7 +95781,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 264 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 267 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -93589,19 +95871,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -93660,13 +95942,13 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return visitImportDeclaration(node); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return visitExportDeclaration(node); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -93846,7 +96128,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 294 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 297 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -93910,7 +96192,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 229 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -93972,10 +96254,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 261 /* NamedImports */: + case 264 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -94155,43 +96437,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return visitVariableStatement(node); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: return visitClassDeclaration(node); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return visitForStatement(node); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return visitForInStatement(node); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return visitForOfStatement(node); - case 232 /* DoStatement */: + case 235 /* DoStatement */: return visitDoStatement(node); - case 233 /* WhileStatement */: + case 236 /* WhileStatement */: return visitWhileStatement(node); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return visitLabeledStatement(node); - case 240 /* WithStatement */: + case 243 /* WithStatement */: return visitWithStatement(node); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: return visitSwitchStatement(node); - case 255 /* CaseBlock */: + case 258 /* CaseBlock */: return visitCaseBlock(node); - case 281 /* CaseClause */: + case 284 /* CaseClause */: return visitCaseClause(node); - case 282 /* DefaultClause */: + case 285 /* DefaultClause */: return visitDefaultClause(node); - case 244 /* TryStatement */: + case 247 /* TryStatement */: return visitTryStatement(node); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return visitCatchClause(node); - case 227 /* Block */: + case 230 /* Block */: return visitBlock(node); - case 333 /* MergeDeclarationMarker */: + case 338 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 334 /* EndOfDeclarationMarker */: + case 339 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -94438,7 +96720,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 294 /* SourceFile */; + return container !== undefined && container.kind === 297 /* SourceFile */; } else { return false; @@ -94471,7 +96753,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 294 /* SourceFile */) { + if (node.kind === 297 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -94521,7 +96803,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -94557,12 +96839,12 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return substituteExpressionIdentifier(node); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return substituteBinaryExpression(node); - case 211 /* PrefixUnaryExpression */: - case 212 /* PostfixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 223 /* MetaProperty */: + case 226 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -94655,14 +96937,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 212 /* PostfixUnaryExpression */ + var expression = node.kind === 215 /* PostfixUnaryExpression */ ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 212 /* PostfixUnaryExpression */) { + if (node.kind === 215 /* PostfixUnaryExpression */) { expression = node.operator === 45 /* PlusPlusToken */ ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1)) : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1)); @@ -94690,7 +96972,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 294 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -94730,7 +97012,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(294 /* SourceFile */); + context.enableEmitNotification(297 /* SourceFile */); context.enableSubstitution(78 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(context, transformSourceFile); @@ -94762,12 +97044,12 @@ var ts; } function visitor(node) { switch (node.kind) { - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return visitExportAssignment(node); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -94794,7 +97076,7 @@ var ts; /*isTypeOnly*/ false, /*name*/ undefined, factory.createNamespaceImport(synthName)), node.moduleSpecifier); ts.setOriginalNode(importDecl, node.exportClause); - var exportDecl = factory.createExportDeclaration( + var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(synthName, oldIdentifier)])); @@ -94901,7 +97183,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 249 /* ClassDeclaration */) { + else if (node.parent.kind === 252 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -94930,7 +97212,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 249 /* ClassDeclaration */) { + else if (node.parent.kind === 252 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -94977,7 +97259,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 246 /* VariableDeclaration */ || node.kind === 195 /* BindingElement */) { + if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -94986,8 +97268,8 @@ var ts; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 162 /* PropertyDeclaration */ || node.kind === 198 /* PropertyAccessExpression */ || node.kind === 161 /* PropertySignature */ || - (node.kind === 159 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 163 /* PropertyDeclaration */ || node.kind === 201 /* PropertyAccessExpression */ || node.kind === 162 /* PropertySignature */ || + (node.kind === 160 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasSyntacticModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -94996,7 +97278,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 249 /* ClassDeclaration */ || node.kind === 159 /* Parameter */) { + else if (node.parent.kind === 252 /* ClassDeclaration */ || node.kind === 160 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -95021,7 +97303,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 167 /* SetAccessor */) { + if (node.kind === 168 /* SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.hasSyntacticModifier(node, 32 /* Static */)) { @@ -95060,26 +97342,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 169 /* ConstructSignature */: + case 170 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 168 /* CallSignature */: + case 169 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 170 /* IndexSignature */: + case 171 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: if (ts.hasSyntacticModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -95087,7 +97369,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 249 /* ClassDeclaration */) { + else if (node.parent.kind === 252 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -95101,7 +97383,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -95126,30 +97408,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 165 /* Constructor */: + case 166 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 169 /* ConstructSignature */: - case 174 /* ConstructorType */: + case 170 /* ConstructSignature */: + case 175 /* ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 168 /* CallSignature */: + case 169 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 170 /* IndexSignature */: + case 171 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -95157,7 +97439,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 249 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 252 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -95170,15 +97452,15 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 248 /* FunctionDeclaration */: - case 173 /* FunctionType */: + case 251 /* FunctionDeclaration */: + case 174 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 167 /* SetAccessor */: - case 166 /* GetAccessor */: + case 168 /* SetAccessor */: + case 167 /* GetAccessor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -95192,39 +97474,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 189 /* MappedType */: + case 190 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 174 /* ConstructorType */: - case 169 /* ConstructSignature */: + case 175 /* ConstructorType */: + case 170 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 168 /* CallSignature */: + case 169 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 249 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 252 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 173 /* FunctionType */: - case 248 /* FunctionDeclaration */: + case 174 /* FunctionType */: + case 251 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -95288,7 +97570,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 159 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 160 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -95343,6 +97625,7 @@ var ts; reportCyclicStructureError: reportCyclicStructureError, reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression, reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError, + reportTruncationError: reportTruncationError, moduleResolverHost: host, trackReferencedAmbientModule: trackReferencedAmbientModule, trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode, @@ -95442,6 +97725,11 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } + function reportTruncationError() { + if (errorNameNode) { + context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); + } + } function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) { var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; }); @@ -95463,10 +97751,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 294 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 297 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 295 /* Bundle */) { + if (node.kind === 298 /* Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -95496,7 +97784,7 @@ var ts; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 297 /* InputFiles */) { + if (prepend.kind === 300 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -95637,7 +97925,7 @@ var ts; return name; } else { - if (name.kind === 194 /* ArrayBindingPattern */) { + if (name.kind === 197 /* ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -95645,7 +97933,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 219 /* OmittedExpression */) { + if (elem.kind === 222 /* OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -95683,7 +97971,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 159 /* Parameter */ && + var shouldUseResolverType = node.kind === 160 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -95692,7 +97980,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(128 /* AnyKeyword */); } - if (node.kind === 167 /* SetAccessor */) { + if (node.kind === 168 /* SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) return factory.createKeywordTypeNode(128 /* AnyKeyword */); @@ -95703,12 +97991,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 246 /* VariableDeclaration */ || node.kind === 195 /* BindingElement */) { + if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 159 /* Parameter */ - || node.kind === 162 /* PropertyDeclaration */ - || node.kind === 161 /* PropertySignature */) { + if (node.kind === 160 /* Parameter */ + || node.kind === 163 /* PropertyDeclaration */ + || node.kind === 162 /* PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -95725,20 +98013,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 248 /* FunctionDeclaration */: - case 253 /* ModuleDeclaration */: - case 250 /* InterfaceDeclaration */: - case 249 /* ClassDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 252 /* EnumDeclaration */: + case 251 /* FunctionDeclaration */: + case 256 /* ModuleDeclaration */: + case 253 /* InterfaceDeclaration */: + case 252 /* ClassDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 255 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 257 /* ImportEqualsDeclaration */: - case 258 /* ImportDeclaration */: - case 264 /* ExportDeclaration */: - case 263 /* ExportAssignment */: + case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportDeclaration */: + case 267 /* ExportDeclaration */: + case 266 /* ExportAssignment */: return false; } return false; @@ -95819,7 +98107,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 253 /* ModuleDeclaration */ && parent.kind !== 192 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 /* ModuleDeclaration */ && parent.kind !== 195 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -95839,7 +98127,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 269 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 272 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -95866,7 +98154,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 260 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 263 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -95961,7 +98249,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 176 /* TypeLiteral */ || input.kind === 189 /* MappedType */) && input.parent.kind !== 251 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 /* TypeLiteral */ || input.kind === 190 /* MappedType */) && input.parent.kind !== 254 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasEffectiveModifier(input, 8 /* Private */)) { @@ -95982,21 +98270,21 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 220 /* ExpressionWithTypeArguments */: { + case 223 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 172 /* TypeReference */: { + case 173 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 169 /* ConstructSignature */: + case 170 /* ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 165 /* Constructor */: { + case 166 /* Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, @@ -96004,7 +98292,7 @@ var ts; /*body*/ undefined); return cleanup(ctor); } - case 164 /* MethodDeclaration */: { + case 165 /* MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -96014,7 +98302,7 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 166 /* GetAccessor */: { + case 167 /* GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -96023,7 +98311,7 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 167 /* SetAccessor */: { + case 168 /* SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -96031,31 +98319,31 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), /*body*/ undefined)); } - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 161 /* PropertySignature */: + case 162 /* PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 163 /* MethodSignature */: { + case 164 /* MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 168 /* CallSignature */: { + case 169 /* CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 170 /* IndexSignature */: { + case 171 /* IndexSignature */: { return cleanup(factory.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128 /* AnyKeyword */))); } - case 246 /* VariableDeclaration */: { + case 249 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -96063,13 +98351,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 158 /* TypeParameter */: { + case 159 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 183 /* ConditionalType */: { + case 184 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -96081,13 +98369,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 173 /* FunctionType */: { + case 174 /* FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 174 /* ConstructorType */: { + case 175 /* ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 192 /* ImportType */: { + case 195 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -96119,7 +98407,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 164 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 165 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -96129,7 +98417,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 264 /* ExportDeclaration */: { + case 267 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -96139,7 +98427,7 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 263 /* ExportAssignment */: { + case 266 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -96178,10 +98466,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 257 /* ImportEqualsDeclaration */: { + case 260 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 258 /* ImportDeclaration */: { + case 261 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -96202,14 +98490,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 251 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 254 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 250 /* InterfaceDeclaration */: { + case 253 /* InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 248 /* FunctionDeclaration */: { + case 251 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -96276,10 +98564,10 @@ var ts; return clean; } } - case 253 /* ModuleDeclaration */: { + case 256 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 254 /* ModuleBlock */) { + if (inner && inner.kind === 257 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -96322,7 +98610,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 249 /* ClassDeclaration */: { + case 252 /* ClassDeclaration */: { var modifiers = factory.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -96403,10 +98691,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 229 /* VariableStatement */: { + case 232 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 252 /* EnumDeclaration */: { + case 255 /* EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -96425,7 +98713,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 253 /* ModuleDeclaration */) { + if (input.kind === 256 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -96446,7 +98734,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 219 /* OmittedExpression */) { + if (e.kind === 222 /* OmittedExpression */) { return; } if (e.name) { @@ -96496,7 +98784,7 @@ var ts; function ensureModifierFlags(node) { var mask = 11263 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 294 /* SourceFile */; + var parentIsFile = node.parent.kind === 297 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -96525,7 +98813,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 250 /* InterfaceDeclaration */) { + if (node.kind === 253 /* InterfaceDeclaration */) { return true; } return false; @@ -96550,7 +98838,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 166 /* GetAccessor */ + return accessor.kind === 167 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -96559,52 +98847,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 159 /* Parameter */: - case 246 /* VariableDeclaration */: + case 160 /* Parameter */: + case 249 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 248 /* FunctionDeclaration */: - case 253 /* ModuleDeclaration */: - case 257 /* ImportEqualsDeclaration */: - case 250 /* InterfaceDeclaration */: - case 249 /* ClassDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 252 /* EnumDeclaration */: - case 229 /* VariableStatement */: - case 258 /* ImportDeclaration */: - case 264 /* ExportDeclaration */: - case 263 /* ExportAssignment */: + case 251 /* FunctionDeclaration */: + case 256 /* ModuleDeclaration */: + case 260 /* ImportEqualsDeclaration */: + case 253 /* InterfaceDeclaration */: + case 252 /* ClassDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 255 /* EnumDeclaration */: + case 232 /* VariableStatement */: + case 261 /* ImportDeclaration */: + case 267 /* ExportDeclaration */: + case 266 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 169 /* ConstructSignature */: - case 165 /* Constructor */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 163 /* MethodSignature */: - case 168 /* CallSignature */: - case 170 /* IndexSignature */: - case 246 /* VariableDeclaration */: - case 158 /* TypeParameter */: - case 220 /* ExpressionWithTypeArguments */: - case 172 /* TypeReference */: - case 183 /* ConditionalType */: - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 192 /* ImportType */: + case 170 /* ConstructSignature */: + case 166 /* Constructor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 164 /* MethodSignature */: + case 169 /* CallSignature */: + case 171 /* IndexSignature */: + case 249 /* VariableDeclaration */: + case 159 /* TypeParameter */: + case 223 /* ExpressionWithTypeArguments */: + case 173 /* TypeReference */: + case 184 /* ConditionalType */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 195 /* ImportType */: return true; } return false; @@ -96648,14 +98936,13 @@ var ts; function getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) { if (emitOnlyDtsFiles) return ts.emptyArray; - var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory)); transformers.push(ts.transformTypeScript); transformers.push(ts.transformClassFields); - if (jsx === 2 /* React */) { + if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } if (languageVersion < 99 /* ESNext */) { @@ -96737,7 +99024,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(336 /* Count */); + var enabledSyntaxKindFeatures = new Array(341 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -96810,7 +99097,13 @@ var ts; // prevent modification of transformation hooks. state = 1 /* Initialized */; // Transform each node. - var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot); + var transformed = []; + for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { + var node = nodes_3[_a]; + ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 297 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); + ts.tracing.pop(); + } // prevent modification of the lexical environment. state = 2 /* Completed */; ts.performance.mark("afterTransform"); @@ -97046,8 +99339,8 @@ var ts; function dispose() { if (state < 3 /* Disposed */) { // Clean up emit nodes on parse tree - for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { - var node = nodes_3[_i]; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); } // Release references to external entries for GC purposes. @@ -97179,7 +99472,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 295 /* Bundle */) { + if (sourceFile.kind === 298 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -97375,9 +99668,15 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } + ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); + ts.tracing.pop(); + ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); + ts.tracing.pop(); + ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); + ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -97509,7 +99808,7 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 294 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 297 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -97532,8 +99831,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 295 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 294 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 298 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 297 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -97574,7 +99873,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 294 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 297 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -97618,16 +99917,16 @@ var ts; if (ts.getRootLength(sourceMapDir) === 0) { // The relative paths are relative to the common directory sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath + return encodeURI(ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath ts.combinePaths(sourceMapDir, sourceMapFile), // this is where user expects to see sourceMap host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + /*isAbsolutePathAnUrl*/ true)); } else { - return ts.combinePaths(sourceMapDir, sourceMapFile); + return encodeURI(ts.combinePaths(sourceMapDir, sourceMapFile)); } } - return sourceMapFile; + return encodeURI(sourceMapFile); } } ts.emitFiles = emitFiles; @@ -97842,6 +100141,8 @@ var ts; var sourceMapGenerator; var sourceMapSource; var sourceMapSourceIndex = -1; + var mostRecentlyAddedSourceMapSource; + var mostRecentlyAddedSourceMapSourceIndex = -1; // Comments var containerPos = -1; var containerEnd = -1; @@ -97880,9 +100181,9 @@ var ts; break; } switch (node.kind) { - case 294 /* SourceFile */: return printFile(node); - case 295 /* Bundle */: return printBundle(node); - case 296 /* UnparsedSource */: return printUnparsedSource(node); + case 297 /* SourceFile */: return printFile(node); + case 298 /* Bundle */: return printBundle(node); + case 299 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -98138,12 +100439,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 294 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 297 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 294 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 297 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -98185,15 +100486,15 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); - case 296 /* UnparsedSource */: - case 290 /* UnparsedPrepend */: + case 299 /* UnparsedSource */: + case 293 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 289 /* UnparsedPrologue */: + case 292 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 291 /* UnparsedText */: - case 292 /* UnparsedInternalText */: + case 294 /* UnparsedText */: + case 295 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 293 /* UnparsedSyntheticReference */: + case 296 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers case 78 /* Identifier */: @@ -98203,262 +100504,270 @@ var ts; return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: return emitQualifiedName(node); - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: return emitTypeParameter(node); - case 159 /* Parameter */: + case 160 /* Parameter */: return emitParameter(node); - case 160 /* Decorator */: + case 161 /* Decorator */: return emitDecorator(node); // Type members - case 161 /* PropertySignature */: + case 162 /* PropertySignature */: return emitPropertySignature(node); - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 163 /* MethodSignature */: + case 164 /* MethodSignature */: return emitMethodSignature(node); - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 165 /* Constructor */: + case 166 /* Constructor */: return emitConstructor(node); - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return emitAccessorDeclaration(node); - case 168 /* CallSignature */: + case 169 /* CallSignature */: return emitCallSignature(node); - case 169 /* ConstructSignature */: + case 170 /* ConstructSignature */: return emitConstructSignature(node); - case 170 /* IndexSignature */: + case 171 /* IndexSignature */: return emitIndexSignature(node); + case 194 /* TemplateLiteralTypeSpan */: + return emitTemplateTypeSpan(node); // Types - case 171 /* TypePredicate */: + case 172 /* TypePredicate */: return emitTypePredicate(node); - case 172 /* TypeReference */: + case 173 /* TypeReference */: return emitTypeReference(node); - case 173 /* FunctionType */: + case 174 /* FunctionType */: return emitFunctionType(node); - case 304 /* JSDocFunctionType */: + case 308 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 174 /* ConstructorType */: + case 175 /* ConstructorType */: return emitConstructorType(node); - case 175 /* TypeQuery */: + case 176 /* TypeQuery */: return emitTypeQuery(node); - case 176 /* TypeLiteral */: + case 177 /* TypeLiteral */: return emitTypeLiteral(node); - case 177 /* ArrayType */: + case 178 /* ArrayType */: return emitArrayType(node); - case 178 /* TupleType */: + case 179 /* TupleType */: return emitTupleType(node); - case 179 /* OptionalType */: + case 180 /* OptionalType */: return emitOptionalType(node); - case 181 /* UnionType */: + case 182 /* UnionType */: return emitUnionType(node); - case 182 /* IntersectionType */: + case 183 /* IntersectionType */: return emitIntersectionType(node); - case 183 /* ConditionalType */: + case 184 /* ConditionalType */: return emitConditionalType(node); - case 184 /* InferType */: + case 185 /* InferType */: return emitInferType(node); - case 185 /* ParenthesizedType */: + case 186 /* ParenthesizedType */: return emitParenthesizedType(node); - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 186 /* ThisType */: + case 187 /* ThisType */: return emitThisType(); - case 187 /* TypeOperator */: + case 188 /* TypeOperator */: return emitTypeOperator(node); - case 188 /* IndexedAccessType */: + case 189 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 189 /* MappedType */: + case 190 /* MappedType */: return emitMappedType(node); - case 190 /* LiteralType */: + case 191 /* LiteralType */: return emitLiteralType(node); - case 192 /* ImportType */: + case 193 /* TemplateLiteralType */: + return emitTemplateType(node); + case 195 /* ImportType */: return emitImportTypeNode(node); - case 299 /* JSDocAllType */: + case 303 /* JSDocAllType */: writePunctuation("*"); return; - case 300 /* JSDocUnknownType */: + case 304 /* JSDocUnknownType */: writePunctuation("?"); return; - case 301 /* JSDocNullableType */: + case 305 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 302 /* JSDocNonNullableType */: + case 306 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 303 /* JSDocOptionalType */: + case 307 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 180 /* RestType */: - case 305 /* JSDocVariadicType */: + case 181 /* RestType */: + case 309 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 191 /* NamedTupleMember */: + case 192 /* NamedTupleMember */: return emitNamedTupleMember(node); // Binding patterns - case 193 /* ObjectBindingPattern */: + case 196 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 194 /* ArrayBindingPattern */: + case 197 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 195 /* BindingElement */: + case 198 /* BindingElement */: return emitBindingElement(node); // Misc - case 225 /* TemplateSpan */: + case 228 /* TemplateSpan */: return emitTemplateSpan(node); - case 226 /* SemicolonClassElement */: + case 229 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 227 /* Block */: + case 230 /* Block */: return emitBlock(node); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return emitVariableStatement(node); - case 228 /* EmptyStatement */: + case 231 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return emitExpressionStatement(node); - case 231 /* IfStatement */: + case 234 /* IfStatement */: return emitIfStatement(node); - case 232 /* DoStatement */: + case 235 /* DoStatement */: return emitDoStatement(node); - case 233 /* WhileStatement */: + case 236 /* WhileStatement */: return emitWhileStatement(node); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return emitForStatement(node); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: return emitForInStatement(node); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: return emitForOfStatement(node); - case 237 /* ContinueStatement */: + case 240 /* ContinueStatement */: return emitContinueStatement(node); - case 238 /* BreakStatement */: + case 241 /* BreakStatement */: return emitBreakStatement(node); - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: return emitReturnStatement(node); - case 240 /* WithStatement */: + case 243 /* WithStatement */: return emitWithStatement(node); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: return emitSwitchStatement(node); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: return emitLabeledStatement(node); - case 243 /* ThrowStatement */: + case 246 /* ThrowStatement */: return emitThrowStatement(node); - case 244 /* TryStatement */: + case 247 /* TryStatement */: return emitTryStatement(node); - case 245 /* DebuggerStatement */: + case 248 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 247 /* VariableDeclarationList */: + case 250 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: return emitClassDeclaration(node); - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 254 /* ModuleBlock */: + case 257 /* ModuleBlock */: return emitModuleBlock(node); - case 255 /* CaseBlock */: + case 258 /* CaseBlock */: return emitCaseBlock(node); - case 256 /* NamespaceExportDeclaration */: + case 259 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return emitImportDeclaration(node); - case 259 /* ImportClause */: + case 262 /* ImportClause */: return emitImportClause(node); - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: return emitNamespaceImport(node); - case 266 /* NamespaceExport */: + case 269 /* NamespaceExport */: return emitNamespaceExport(node); - case 261 /* NamedImports */: + case 264 /* NamedImports */: return emitNamedImports(node); - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: return emitImportSpecifier(node); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return emitExportAssignment(node); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: return emitExportDeclaration(node); - case 265 /* NamedExports */: + case 268 /* NamedExports */: return emitNamedExports(node); - case 267 /* ExportSpecifier */: + case 270 /* ExportSpecifier */: return emitExportSpecifier(node); - case 268 /* MissingDeclaration */: + case 271 /* MissingDeclaration */: return; // Module references - case 269 /* ExternalModuleReference */: + case 272 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 272 /* JsxOpeningElement */: - case 275 /* JsxOpeningFragment */: + case 275 /* JsxOpeningElement */: + case 278 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 273 /* JsxClosingElement */: - case 276 /* JsxClosingFragment */: + case 276 /* JsxClosingElement */: + case 279 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 277 /* JsxAttribute */: + case 280 /* JsxAttribute */: return emitJsxAttribute(node); - case 278 /* JsxAttributes */: + case 281 /* JsxAttributes */: return emitJsxAttributes(node); - case 279 /* JsxSpreadAttribute */: + case 282 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 280 /* JsxExpression */: + case 283 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 281 /* CaseClause */: + case 284 /* CaseClause */: return emitCaseClause(node); - case 282 /* DefaultClause */: + case 285 /* DefaultClause */: return emitDefaultClause(node); - case 283 /* HeritageClause */: + case 286 /* HeritageClause */: return emitHeritageClause(node); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 287 /* SpreadAssignment */: + case 290 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 288 /* EnumMember */: + case 291 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 322 /* JSDocParameterTag */: - case 328 /* JSDocPropertyTag */: + case 326 /* JSDocParameterTag */: + case 333 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 323 /* JSDocReturnTag */: - case 325 /* JSDocTypeTag */: - case 324 /* JSDocThisTag */: - case 321 /* JSDocEnumTag */: + case 327 /* JSDocReturnTag */: + case 329 /* JSDocTypeTag */: + case 328 /* JSDocThisTag */: + case 325 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 312 /* JSDocImplementsTag */: - case 311 /* JSDocAugmentsTag */: + case 316 /* JSDocImplementsTag */: + case 315 /* JSDocAugmentsTag */: return emitJSDocHeritageTag(node); - case 326 /* JSDocTemplateTag */: + case 330 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 327 /* JSDocTypedefTag */: + case 331 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 320 /* JSDocCallbackTag */: + case 324 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 309 /* JSDocSignature */: + case 313 /* JSDocSignature */: return emitJSDocSignature(node); - case 308 /* JSDocTypeLiteral */: + case 312 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 315 /* JSDocClassTag */: - case 310 /* JSDocTag */: + case 319 /* JSDocClassTag */: + case 314 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 307 /* JSDocComment */: + case 332 /* JSDocSeeTag */: + return emitJSDocSeeTag(node); + case 302 /* JSDocNameReference */: + return emitJSDocNameReference(node); + case 311 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -98495,71 +100804,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return emitCallExpression(node); - case 201 /* NewExpression */: + case 204 /* NewExpression */: return emitNewExpression(node); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 203 /* TypeAssertionExpression */: + case 206 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: return emitFunctionExpression(node); - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return emitArrowFunction(node); - case 207 /* DeleteExpression */: + case 210 /* DeleteExpression */: return emitDeleteExpression(node); - case 208 /* TypeOfExpression */: + case 211 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 209 /* VoidExpression */: + case 212 /* VoidExpression */: return emitVoidExpression(node); - case 210 /* AwaitExpression */: + case 213 /* AwaitExpression */: return emitAwaitExpression(node); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return emitBinaryExpression(node); - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return emitConditionalExpression(node); - case 215 /* TemplateExpression */: + case 218 /* TemplateExpression */: return emitTemplateExpression(node); - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: return emitYieldExpression(node); - case 217 /* SpreadElement */: + case 220 /* SpreadElement */: return emitSpreadExpression(node); - case 218 /* ClassExpression */: + case 221 /* ClassExpression */: return emitClassExpression(node); - case 219 /* OmittedExpression */: + case 222 /* OmittedExpression */: return; - case 221 /* AsExpression */: + case 224 /* AsExpression */: return emitAsExpression(node); - case 222 /* NonNullExpression */: + case 225 /* NonNullExpression */: return emitNonNullExpression(node); - case 223 /* MetaProperty */: + case 226 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 270 /* JsxElement */: + case 273 /* JsxElement */: return emitJsxElement(node); - case 271 /* JsxSelfClosingElement */: + case 274 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 274 /* JsxFragment */: + case 277 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 331 /* PartiallyEmittedExpression */: + case 336 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 332 /* CommaListExpression */: + case 337 /* CommaListExpression */: return emitCommaList(node); } } @@ -98601,7 +100910,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 295 /* Bundle */ ? node : undefined; + var bundle = node.kind === 298 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -98701,7 +101010,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 291 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -98774,7 +101083,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 304 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 308 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -98836,7 +101145,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 166 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 167 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -98870,6 +101179,10 @@ var ts; emitTypeAnnotation(node.type); writeTrailingSemicolon(); } + function emitTemplateTypeSpan(node) { + emit(node.type); + emit(node.literal); + } function emitSemicolonClassElement() { writeTrailingSemicolon(); } @@ -99028,13 +101341,19 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 141 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 142 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + if (node.nameType) { + writeSpace(); + writeKeyword("as"); + writeSpace(); + emit(node.nameType); + } writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); @@ -99058,6 +101377,10 @@ var ts; function emitLiteralType(node) { emitExpression(node.literal); } + function emitTemplateType(node) { + emit(node.head); + emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + } function emitImportTypeNode(node) { if (node.isTypeOf) { writeKeyword("typeof"); @@ -99256,7 +101579,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 211 /* PrefixUnaryExpression */ + return operand.kind === 214 /* PrefixUnaryExpression */ && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } @@ -99444,7 +101767,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); emitTokenWithComment(90 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 231 /* IfStatement */) { + if (node.elseStatement.kind === 234 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -99507,7 +101830,7 @@ var ts; emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(155 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(156 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -99515,7 +101838,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 247 /* VariableDeclarationList */) { + if (node.kind === 250 /* VariableDeclarationList */) { emit(node); } else { @@ -99811,7 +102134,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 253 /* ModuleDeclaration */) { + while (body.kind === 256 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -99856,7 +102179,7 @@ var ts; if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(152 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(153 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -99864,7 +102187,7 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(148 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -99904,7 +102227,7 @@ var ts; var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(148 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(149 /* TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { @@ -99916,7 +102239,7 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(152 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(153 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -99927,7 +102250,7 @@ var ts; writeSpace(); nextPos = emitTokenWithComment(126 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(139 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(140 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -100150,7 +102473,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 325 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 329 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -100166,6 +102489,17 @@ var ts; emitJSDocTypeExpression(tag.typeExpression); emitJSDocComment(tag.comment); } + function emitJSDocSeeTag(tag) { + emitJSDocTagName(tag.tagName); + emit(tag.name); + emitJSDocComment(tag.comment); + } + function emitJSDocNameReference(node) { + writeSpace(); + writePunctuation("{"); + emit(node.name); + writePunctuation("}"); + } function emitJSDocHeritageTag(tag) { emitJSDocTagName(tag.tagName); writeSpace(); @@ -100184,7 +102518,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 298 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -100203,7 +102537,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 308 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 312 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -100337,8 +102671,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_22 = types; _d < types_22.length; _d++) { - var directive = types_22[_d]; + for (var _d = 0, types_23 = types; _d < types_23.length; _d++) { + var directive = types_23[_d]; var pos = writer.getTextPos(); writeComment("/// <reference types=\"" + directive.fileName + "\" />"); if (bundleFileInfo) @@ -101067,7 +103401,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 204 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 207 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -101100,7 +103434,10 @@ var ts; return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - return ts.getLiteralText(node, currentSourceFile, neverAsciiEscape, jsxAttributeEscape); + var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0); + return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. @@ -101133,84 +103470,84 @@ var ts; if (!node) return; switch (node.kind) { - case 227 /* Block */: + case 230 /* Block */: ts.forEach(node.statements, generateNames); break; - case 242 /* LabeledStatement */: - case 240 /* WithStatement */: - case 232 /* DoStatement */: - case 233 /* WhileStatement */: + case 245 /* LabeledStatement */: + case 243 /* WithStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: generateNames(node.statement); break; - case 231 /* IfStatement */: + case 234 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 234 /* ForStatement */: - case 236 /* ForOfStatement */: - case 235 /* ForInStatement */: + case 237 /* ForStatement */: + case 239 /* ForOfStatement */: + case 238 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 255 /* CaseBlock */: + case 258 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 281 /* CaseClause */: - case 282 /* DefaultClause */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 244 /* TryStatement */: + case 247 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 284 /* CatchClause */: + case 287 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: generateNames(node.declarationList); break; - case 247 /* VariableDeclarationList */: + case 250 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 246 /* VariableDeclaration */: - case 159 /* Parameter */: - case 195 /* BindingElement */: - case 249 /* ClassDeclaration */: + case 249 /* VariableDeclaration */: + case 160 /* Parameter */: + case 198 /* BindingElement */: + case 252 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 193 /* ObjectBindingPattern */: - case 194 /* ArrayBindingPattern */: + case 196 /* ObjectBindingPattern */: + case 197 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: generateNames(node.importClause); break; - case 259 /* ImportClause */: + case 262 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 266 /* NamespaceExport */: + case 269 /* NamespaceExport */: generateNameIfNeeded(node.name); break; - case 261 /* NamedImports */: + case 264 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -101219,12 +103556,12 @@ var ts; if (!node) return; switch (node.kind) { - case 285 /* PropertyAssignment */: - case 286 /* ShorthandPropertyAssignment */: - case 162 /* PropertyDeclaration */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 288 /* PropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: + case 163 /* PropertyDeclaration */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -101406,23 +103743,23 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 253 /* ModuleDeclaration */: - case 252 /* EnumDeclaration */: + case 256 /* ModuleDeclaration */: + case 255 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 258 /* ImportDeclaration */: - case 264 /* ExportDeclaration */: + case 261 /* ImportDeclaration */: + case 267 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 248 /* FunctionDeclaration */: - case 249 /* ClassDeclaration */: - case 263 /* ExportAssignment */: + case 251 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 266 /* ExportAssignment */: return generateNameForExportDefault(); - case 218 /* ClassExpression */: + case 221 /* ClassExpression */: return generateNameForClassExpression(); - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -101470,7 +103807,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 330 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 335 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -101494,7 +103831,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 247 /* VariableDeclarationList */) { + if (node.kind === 250 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -101587,7 +103924,12 @@ var ts; function emitLeadingComments(pos, isEmittedNode) { hasWrittenComment = false; if (isEmittedNode) { - forEachLeadingCommentToEmit(pos, emitLeadingComment); + if (pos === 0 && (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.isDeclarationFile)) { + forEachLeadingCommentToEmit(pos, emitNonTripleSlashLeadingComment); + } + else { + forEachLeadingCommentToEmit(pos, emitLeadingComment); + } } else if (pos === 0) { // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, @@ -101606,6 +103948,11 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } + function emitNonTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (!isTripleSlashComment(commentPos, commentEnd)) { + emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); + } + } function shouldWriteComment(text, pos) { if (printerOptions.onlyPrintJsDocStyle) { return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); @@ -101753,7 +104100,7 @@ var ts; else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 330 /* NotEmittedStatement */ + if (node.kind !== 335 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -101766,7 +104113,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 330 /* NotEmittedStatement */ + if (node.kind !== 335 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -101799,9 +104146,10 @@ var ts; function emitSourcePos(source, pos) { if (source !== sourceMapSource) { var savedSourceMapSource = sourceMapSource; + var savedSourceMapSourceIndex = sourceMapSourceIndex; setSourceMapSource(source); emitPos(pos); - setSourceMapSource(savedSourceMapSource); + resetSourceMapSource(savedSourceMapSource, savedSourceMapSourceIndex); } else { emitPos(pos); @@ -101840,6 +104188,12 @@ var ts; return; } sourceMapSource = source; + if (source === mostRecentlyAddedSourceMapSource) { + // Fast path for when the new source map is the most recently added, in which case + // we use its captured index without going through the source map generator. + sourceMapSourceIndex = mostRecentlyAddedSourceMapSourceIndex; + return; + } if (isJsonSourceMapSource(source)) { return; } @@ -101847,6 +104201,12 @@ var ts; if (printerOptions.inlineSources) { sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text); } + mostRecentlyAddedSourceMapSource = source; + mostRecentlyAddedSourceMapSourceIndex = sourceMapSourceIndex; + } + function resetSourceMapSource(source, sourceIndex) { + sourceMapSource = source; + sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); @@ -102345,6 +104705,7 @@ var ts; if (system === void 0) { system = ts.sys; } var existingDirectories = new ts.Map(); var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames); + var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash; function getSourceFile(fileName, languageVersion, onError) { var text; try { @@ -102389,14 +104750,14 @@ var ts; } var outputFingerprints; function writeFileWorker(fileName, data, writeByteOrderMark) { - if (!ts.isWatchSet(options) || !system.createHash || !system.getModifiedTime) { + if (!ts.isWatchSet(options) || !system.getModifiedTime) { system.writeFile(fileName, data, writeByteOrderMark); return; } if (!outputFingerprints) { outputFingerprints = new ts.Map(); } - var hash = system.createHash(data); + var hash = computeHash(data); var mtimeBefore = system.getModifiedTime(fileName); if (mtimeBefore) { var fingerprint = outputFingerprints.get(fileName); @@ -102749,6 +105110,35 @@ var ts; } ts.loadWithLocalCache = loadWithLocalCache; /* @internal */ + function forEachResolvedProjectReference(resolvedProjectReferences, cb) { + return forEachProjectReference(/*projectReferences*/ undefined, resolvedProjectReferences, function (resolvedRef, parent) { return resolvedRef && cb(resolvedRef, parent); }); + } + ts.forEachResolvedProjectReference = forEachResolvedProjectReference; + function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { + var seenResolvedRefs; + return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined); + function worker(projectReferences, resolvedProjectReferences, parent) { + // Visit project references first + if (cbRef) { + var result = cbRef(projectReferences, parent); + if (result) { + return result; + } + } + return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) { + if (resolvedRef && (seenResolvedRefs === null || seenResolvedRefs === void 0 ? void 0 : seenResolvedRefs.has(resolvedRef.sourceFile.path))) { + // ignore recursives + return undefined; + } + var result = cbResolvedRef(resolvedRef, parent, index); + if (result || !resolvedRef) + return result; + (seenResolvedRefs || (seenResolvedRefs = new ts.Set())).add(resolvedRef.sourceFile.path); + return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef); + }); + } + } + /* @internal */ ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated @@ -102884,6 +105274,8 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); + var tracingData = ["program" /* Program */, "createProgram"]; + ts.tracing.begin.apply(ts.tracing, tracingData); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -102959,12 +105351,16 @@ var ts; getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _c.onProgramCreateComplete, fileExists = _c.fileExists, directoryExists = _c.directoryExists; + ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); + ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. - var structuralIsReused; - structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const - if (structuralIsReused !== 2 /* Completely */) { + var structureIsReused; + ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const + ts.tracing.pop(); + if (structureIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -103001,10 +105397,13 @@ var ts; } } } + ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false); }); + ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { + ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); @@ -103012,6 +105411,7 @@ var ts; for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); } + ts.tracing.pop(); } // Do not process the default library if: // - The '--noLib' flag is used. @@ -103052,8 +105452,8 @@ var ts; host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } - oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) { - if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) { + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { + if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); } }); @@ -103087,6 +105487,7 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, + getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); }, getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); }, @@ -103115,26 +105516,73 @@ var ts; getSymlinkCache: getSymlinkCache, realpath: (_b = host.realpath) === null || _b === void 0 ? void 0 : _b.bind(host), useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, + structureIsReused: structureIsReused, }; onProgramCreateComplete(); verifyCompilerOptions(); ts.performance.mark("afterProgram"); ts.performance.measure("Program", "beforeProgram", "afterProgram"); + ts.tracing.end.apply(ts.tracing, tracingData); return program; - function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference) { + function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { + if (!moduleNames.length) + return ts.emptyArray; + var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); + var redirectedReference = getRedirectReferenceForResolution(containingFile); + ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); - var result = actualResolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference); + var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); + ts.tracing.pop(); return result; } - function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference) { + function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { + if (!typeDirectiveNames.length) + return []; + var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; + var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; + ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); - var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference); + var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference); ts.performance.mark("afterResolveTypeReference"); ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference"); + ts.tracing.pop(); return result; } + function getRedirectReferenceForResolution(file) { + var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName); + if (redirect || !ts.fileExtensionIs(file.originalFileName, ".d.ts" /* Dts */)) + return redirect; + // The originalFileName could not be actual source file name if file found was d.ts from referecned project + // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case + var resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject(file.originalFileName, file.path); + if (resultFromDts) + return resultFromDts; + // If preserveSymlinks is true, module resolution wont jump the symlink + // but the resolved real path may be the .d.ts from project reference + // Note:: Currently we try the real path only if the + // file is from node_modules to avoid having to run real path on all file paths + if (!host.realpath || !options.preserveSymlinks || !ts.stringContains(file.originalFileName, ts.nodeModulesPathPart)) + return undefined; + var realDeclarationFileName = host.realpath(file.originalFileName); + var realDeclarationPath = toPath(realDeclarationFileName); + return realDeclarationPath === file.path ? undefined : getRedirectReferenceForResolutionFromSourceOfProject(realDeclarationFileName, realDeclarationPath); + } + function getRedirectReferenceForResolutionFromSourceOfProject(fileName, filePath) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (ts.isString(source)) + return getResolvedProjectReferenceToRedirect(source); + if (!source) + return undefined; + // Output of .d.ts file so return resolved ref that matches the out file name + return forEachResolvedProjectReference(function (resolvedRef) { + var out = ts.outFile(resolvedRef.commandLine.options); + if (!out) + return undefined; + return toPath(out) === filePath ? resolvedRef : undefined; + }); + } function compareDefaultLibFiles(a, b) { return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b)); } @@ -103193,13 +105641,13 @@ var ts; } return classifiableNames; } - function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) { - if (structuralIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + function resolveModuleNamesReusingOldState(moduleNames, file) { + if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. - return resolveModuleNamesWorker(moduleNames, containingFile, /*reusedNames*/ undefined, getResolvedProjectReferenceToRedirect(file.originalFileName)); + return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); } - var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile); + var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName); if (oldSourceFile !== file && file.resolvedModules) { // `file` was created for the new program. // @@ -103209,13 +105657,13 @@ var ts; // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - var result_12 = []; + var result_14 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; var resolvedModule = file.resolvedModules.get(moduleName); - result_12.push(resolvedModule); + result_14.push(resolvedModule); } - return result_12; + return result_14; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules @@ -103243,7 +105691,7 @@ var ts; var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName); if (oldResolvedModule) { if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, containingFile); + ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory)); } (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule; (reusedNames || (reusedNames = [])).push(moduleName); @@ -103258,7 +105706,7 @@ var ts; if (ts.contains(file.ambientModuleNames, moduleName)) { resolvesToAmbientModuleInNonModifiedFile = true; if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, containingFile); + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory)); } } else { @@ -103273,7 +105721,7 @@ var ts; } } var resolutions = unknownModuleNames && unknownModuleNames.length - ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName)) + ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames) : ts.emptyArray; // Combine results of resolutions and predicted results if (!result) { @@ -103321,7 +105769,7 @@ var ts; } } function canReuseProjectReferences() { - return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) { + return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) { var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var newResolvedRef = parseProjectReferenceConfigFile(newRef); if (oldResolvedRef) { @@ -103347,19 +105795,19 @@ var ts; // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -103367,12 +105815,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - oldProgram.structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -103387,7 +105835,7 @@ var ts; ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target, /*onError*/ undefined, shouldCreateNewSourceFile) : host.getSourceFile(oldSourceFile.fileName, options.target, /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; @@ -103396,7 +105844,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -103404,7 +105852,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } fileChanged = false; } @@ -103423,7 +105871,7 @@ var ts; var prevKind = seenPackageNames.get(packageName); var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } seenPackageNames.set(packageName, newKind); } @@ -103431,50 +105879,50 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - return oldProgram.structureIsReused = 0 /* Not */; + return 0 /* Not */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - oldProgram.structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* SafeModules */; } // check tripleslash references if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - oldProgram.structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* SafeModules */; } // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed - oldProgram.structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { // moduleAugmentations has changed - oldProgram.structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* SafeModules */; } if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed - oldProgram.structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* SafeModules */; } if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { // 'types' references has changed - oldProgram.structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* SafeModules */; } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - oldProgram.structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (oldProgram.structureIsReused !== 2 /* Completely */) { - return oldProgram.structureIsReused; + if (structureIsReused !== 2 /* Completely */) { + return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) { @@ -103489,38 +105937,35 @@ var ts; // try to verify results of module resolution for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) { var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile; - var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); var moduleNames = getModuleNames(newSourceFile); - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - oldProgram.structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* SafeModules */; newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); } else { newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } - if (resolveTypeReferenceDirectiveNamesWorker) { - // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. - var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); }); - var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); - // ensure that types resolutions are still correct - var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged_1) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); - } - else { - newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; - } + // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. + var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); }); + var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile); + // ensure that types resolutions are still correct + var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (typeReferenceEesolutionsChanged) { + structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, typeReferenceResolutions); + } + else { + newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (oldProgram.structureIsReused !== 2 /* Completely */) { - return oldProgram.structureIsReused; + if (structureIsReused !== 2 /* Completely */) { + return structureIsReused; } if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) { - return oldProgram.structureIsReused = 1 /* SafeModules */; + return 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); refFileMap = oldProgram.getRefFileMap(); @@ -103554,7 +105999,7 @@ var ts; resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; - return oldProgram.structureIsReused = 2 /* Completely */; + return 2 /* Completely */; } function getEmitHost(writeFileCallback) { return { @@ -103594,6 +106039,8 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); + var tracingData = ["emit" /* Emit */, "emitBuildInfo"]; + ts.tracing.begin.apply(ts.tracing, tracingData); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -103602,6 +106049,7 @@ var ts; /*onlyBuildInfo*/ true); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); + ts.tracing.end.apply(ts.tracing, tracingData); return emitResult; } function getResolvedProjectReferences() { @@ -103647,7 +106095,11 @@ var ts; return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); + var tracingData = ["emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }]; + ts.tracing.begin.apply(ts.tracing, tracingData); + var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); + ts.tracing.end.apply(ts.tracing, tracingData); + return result; } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); @@ -103787,17 +106239,17 @@ var ts; sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; - return getMergedBindAndCheckDiagnostics(sourceFile, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined); + return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined); }); } - function getMergedBindAndCheckDiagnostics(sourceFile) { + function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics) { var _a; var allDiagnostics = []; - for (var _i = 1; _i < arguments.length; _i++) { - allDiagnostics[_i - 1] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + allDiagnostics[_i - 2] = arguments[_i]; } var flatDiagnostics = ts.flatten(allDiagnostics); - if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { + if (!includeBindAndCheckDiagnostics || !((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; } var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives; @@ -103858,22 +106310,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 159 /* Parameter */: - case 162 /* PropertyDeclaration */: - case 164 /* MethodDeclaration */: + case 160 /* Parameter */: + case 163 /* PropertyDeclaration */: + case 165 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 163 /* MethodSignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 205 /* FunctionExpression */: - case 248 /* FunctionDeclaration */: - case 206 /* ArrowFunction */: - case 246 /* VariableDeclaration */: + case 164 /* MethodSignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 208 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 209 /* ArrowFunction */: + case 249 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -103881,58 +106333,58 @@ var ts; } } switch (node.kind) { - case 259 /* ImportClause */: + case 262 /* ImportClause */: if (node.isTypeOnly) { - diagnostics.push(createDiagnosticForNode(node.parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); + diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 283 /* HeritageClause */: + case 286 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 116 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: var interfaceKeyword = ts.tokenToString(117 /* InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 253 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(139 /* NamespaceKeyword */) : ts.tokenToString(138 /* ModuleKeyword */); + case 256 /* ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(140 /* NamespaceKeyword */) : ts.tokenToString(139 /* ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91 /* EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 222 /* NonNullExpression */: + case 225 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 221 /* AsExpression */: + case 224 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 203 /* TypeAssertionExpression */: + case 206 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -103941,29 +106393,29 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 164 /* MethodDeclaration */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 205 /* FunctionExpression */: - case 248 /* FunctionDeclaration */: - case 206 /* ArrowFunction */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 165 /* MethodDeclaration */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 208 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 209 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 229 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 232 /* VariableStatement */); return "skip"; } break; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -103975,19 +106427,19 @@ var ts; return "skip"; } break; - case 159 /* Parameter */: + case 160 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 200 /* CallExpression */: - case 201 /* NewExpression */: - case 220 /* ExpressionWithTypeArguments */: - case 271 /* JsxSelfClosingElement */: - case 272 /* JsxOpeningElement */: - case 202 /* TaggedTemplateExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: + case 223 /* ExpressionWithTypeArguments */: + case 274 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: + case 205 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -104009,7 +106461,7 @@ var ts; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: - case 141 /* ReadonlyKeyword */: + case 142 /* ReadonlyKeyword */: case 133 /* DeclareKeyword */: case 125 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); @@ -104070,9 +106522,7 @@ var ts; } var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName); forEachResolvedProjectReference(function (resolvedRef) { - if (resolvedRef) { - diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName)); - } + diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName)); }); return diagnostics; } @@ -104093,6 +106543,18 @@ var ts; ? b.kind === 78 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } + function createSyntheticImport(text, file) { + var externalHelpersModuleReference = ts.factory.createStringLiteral(text); + var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference); + ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.setParent(externalHelpersModuleReference, importDecl); + ts.setParent(importDecl, file); + // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them + // (which is required to build the dependency graph for incremental emit) + externalHelpersModuleReference.flags &= ~8 /* Synthesized */; + importDecl.flags &= ~8 /* Synthesized */; + return externalHelpersModuleReference; + } function collectExternalModuleReferences(file) { if (file.imports) { return; @@ -104105,16 +106567,17 @@ var ts; var ambientModules; // If we are importing helpers, we need to add a synthetic reference to resolve the // helpers library. - if (options.importHelpers - && (options.isolatedModules || isExternalModuleFile) + if ((options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - // synthesize 'import "tslib"' declaration - var externalHelpersModuleReference = ts.factory.createStringLiteral(ts.externalHelpersModuleNameText); - var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); - ts.setParent(externalHelpersModuleReference, importDecl); - ts.setParent(importDecl, file); - imports = [externalHelpersModuleReference]; + if (options.importHelpers) { + // synthesize 'import "tslib"' declaration + imports = [createSyntheticImport(ts.externalHelpersModuleNameText, file)]; + } + var jsxImport = ts.getJSXRuntimeImport(ts.getJSXImplicitImportBase(options, file), options); + if (jsxImport) { + // synthesize `import "base/jsx-runtime"` declaration + (imports || (imports = [])).push(createSyntheticImport(jsxImport, file)); + } } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; @@ -104298,6 +106761,16 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + ts.tracing.push("program" /* Program */, "findSourceFile", { + fileName: fileName, + isDefaultLib: isDefaultLib || undefined, + refKind: refFile ? ts.RefFileKind[refFile.kind] : undefined, + }); + var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId); + ts.tracing.pop(); + return result; + } + function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { if (useSourceOfProjectReferenceRedirect) { var source = getSourceOfProjectReferenceRedirect(fileName); // If preserveSymlinks is true, module resolution wont jump the symlink @@ -104485,12 +106958,11 @@ var ts; function getResolvedProjectReferenceToRedirect(fileName) { if (mapFromFileToProjectReferenceRedirects === undefined) { mapFromFileToProjectReferenceRedirects = new ts.Map(); - forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) { + forEachResolvedProjectReference(function (referencedProject) { // not input file from the referenced project, ignore - if (referencedProject && - toPath(options.configFilePath) !== referenceProjectPath) { + if (toPath(options.configFilePath) !== referencedProject.sourceFile.path) { referencedProject.commandLine.fileNames.forEach(function (f) { - return mapFromFileToProjectReferenceRedirects.set(toPath(f), referenceProjectPath); + return mapFromFileToProjectReferenceRedirects.set(toPath(f), referencedProject.sourceFile.path); }); } }); @@ -104499,11 +106971,7 @@ var ts; return referencedProjectPath && getResolvedProjectReferenceByPath(referencedProjectPath); } function forEachResolvedProjectReference(cb) { - return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { - var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; - var resolvedRefPath = toPath(resolveProjectReferencePath(ref)); - return cb(resolvedRef, resolvedRefPath); - }); + return ts.forEachResolvedProjectReference(resolvedProjectReferences, cb); } function getSourceOfProjectReferenceRedirect(file) { if (!ts.isDeclarationFileName(file)) @@ -104511,21 +106979,19 @@ var ts; if (mapFromToProjectReferenceRedirectSource === undefined) { mapFromToProjectReferenceRedirectSource = new ts.Map(); forEachResolvedProjectReference(function (resolvedRef) { - if (resolvedRef) { - var out = ts.outFile(resolvedRef.commandLine.options); - if (out) { - // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); - mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); - } - else { - ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { - var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); - mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); - } - }); - } + var out = ts.outFile(resolvedRef.commandLine.options); + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); } }); } @@ -104534,33 +107000,6 @@ var ts; function isSourceOfProjectReferenceRedirect(fileName) { return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); } - function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { - var seenResolvedRefs; - return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); - function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) { - // Visit project references first - if (cbRef) { - var result = cbRef(projectReferences, parent); - if (result) { - return result; - } - } - return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) { - if (ts.contains(seenResolvedRefs, resolvedRef)) { - // ignore recursives - return undefined; - } - var result = cbResolvedRef(resolvedRef, index, parent); - if (result) { - return result; - } - if (!resolvedRef) - return undefined; - (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef); - return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef); - }); - } - } function getResolvedProjectReferenceByPath(projectReferencePath) { if (!projectReferenceRedirects) { return undefined; @@ -104587,7 +107026,7 @@ var ts; if (!typeDirectives) { return; } - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName)); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file); for (var i = 0; i < typeDirectives.length; i++) { var ref = file.typeReferenceDirectives[i]; var resolvedTypeReferenceDirective = resolutions[i]; @@ -104604,6 +107043,11 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { + ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: refFile === null || refFile === void 0 ? void 0 : refFile.kind, refPath: refFile === null || refFile === void 0 ? void 0 : refFile.file.path }); + processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, refFile); + ts.tracing.pop(); + } + function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -104688,7 +107132,7 @@ var ts; if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); - var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, file); ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; @@ -104716,7 +107160,7 @@ var ts; && !options.noResolve && i < file.imports.length && !elideImport - && !(isJsFile && !options.allowJs) + && !(isJsFile && !ts.getAllowJSCompilerOption(options)) && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -104832,9 +107276,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"); } } - if (options.paths && options.baseUrl === undefined) { - createDiagnosticForOptionName(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option, "paths"); - } if (options.composite) { if (options.declaration === false) { createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); @@ -104884,6 +107325,9 @@ var ts; if (!ts.hasZeroOrOneAsteriskCharacter(subst)) { createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key); } + if (!options.baseUrl && !ts.pathIsRelative(subst) && !ts.pathIsAbsolute(subst)) { + createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash); + } } else { createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst); @@ -104936,7 +107380,7 @@ var ts; 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.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided)); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { @@ -104978,7 +107422,7 @@ var ts; if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } - if (options.checkJs && !options.allowJs) { + if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); } if (options.emitDeclarationOnly) { @@ -104997,6 +107441,9 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } + if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); + } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { createOptionValueDiagnostic("jsxFactory", ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory); } @@ -105008,10 +107455,23 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } + if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); + } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { createOptionValueDiagnostic("jsxFragmentFactory", ts.Diagnostics.Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFragmentFactory); } } + if (options.reactNamespace) { + if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); + } + } + if (options.jsxImportSource) { + if (options.jsx === 2 /* React */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); + } + } // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); @@ -105086,7 +107546,7 @@ var ts; } function verifyProjectReferences() { var buildInfoPath = !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; - forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, parent, index) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; if (!resolvedRef) { @@ -105281,8 +107741,6 @@ var ts; if (!setOfDeclarationDirectories) { setOfDeclarationDirectories = new ts.Set(); host.forEachResolvedProjectReference(function (ref) { - if (!ref) - return; var out = ts.outFile(ref.commandLine.options); if (out) { setOfDeclarationDirectories.add(ts.getDirectoryPath(host.toPath(out))); @@ -105515,7 +107973,7 @@ var ts; return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } function needAllowJs() { - return options.allowJs || !ts.getStrictOptionValue(options, "noImplicitAny") ? undefined : ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; + return ts.getAllowJSCompilerOption(options) || !ts.getStrictOptionValue(options, "noImplicitAny") ? undefined : ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } function needResolveJsonModule() { return options.resolveJsonModule ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used; @@ -105669,7 +108127,7 @@ var ts; // Create the reference map, and set the file infos for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - var version_1 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set"); + var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set"); var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined; if (referencedMap) { var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName); @@ -105684,7 +108142,7 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_1, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); + fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); } return { fileInfos: fileInfos, @@ -105786,7 +108244,7 @@ var ts; emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; if (firstDts_1) { ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); - latestSignature = computeHash(firstDts_1.text); + latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } @@ -105979,14 +108437,12 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) { // TODO: GH#18217 - queue.push.apply(// TODO: GH#18217 - queue, getReferencedByPaths(state, currentSourceFile.resolvedPath)); + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) { + queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } } // Return array of values that needs emit - // Return array of values that needs emit return ts.arrayFrom(ts.mapDefinedIterator(seenFileNamesMap.values(), function (value) { return value; })); } })(BuilderState = ts.BuilderState || (ts.BuilderState = {})); @@ -106107,7 +108563,7 @@ var ts; result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map(function (r) { return convertToDiagnosticRelatedInformation(r, newProgram, toPath); }) : - ts.emptyArray : + [] : undefined; return result; }); @@ -106299,10 +108755,10 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } - function isChangedSignagure(state, path) { + function isChangedSignature(state, path) { var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path); - var oldSignagure = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; - return newSignature !== oldSignagure; + var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignature; } /** * Iterate on referencing modules that export entities from affected file @@ -106313,7 +108769,7 @@ var ts; if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) { return; } - if (!isChangedSignagure(state, affectedFile.resolvedPath)) + if (!isChangedSignature(state, affectedFile.resolvedPath)) return; // Since isolated modules dont change js files, files affected by change in signature is itself // But we need to cleanup semantic diagnostics and queue dts emit for affected files @@ -106326,7 +108782,7 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); var result = fn(state, currentPath); - if (result && isChangedSignagure(state, currentPath)) { + if (result && isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); } @@ -106576,7 +109032,7 @@ var ts; result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) : - ts.emptyArray : + [] : undefined; return result; }); @@ -106638,7 +109094,7 @@ var ts; /** * Computing hash to for signature verification */ - var computeHash = host.createHash || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(host, host.createHash); var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); var backupState; newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; @@ -107516,8 +109972,8 @@ var ts; if (!resolutions) return false; var invalidated = false; - for (var _i = 0, resolutions_2 = resolutions; _i < resolutions_2.length; _i++) { - var resolution = resolutions_2[_i]; + for (var _i = 0, resolutions_1 = resolutions; _i < resolutions_1.length; _i++) { + var resolution = resolutions_1[_i]; if (resolution.isInvalidated || !canInvalidate(resolution)) continue; resolution.isInvalidated = invalidated = true; @@ -107729,14 +110185,14 @@ var ts; function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host); - return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, /*packageNameOnly*/ true); }); } moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host); - return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || - getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); + return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) || + getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); } /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) { @@ -107747,8 +110203,46 @@ var ts; var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); - var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); - return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); + var importedFileIsInNodeModules = ts.some(modulePaths, function (p) { return p.isInNodeModules; }); + // Module specifier priority: + // 1. "Bare package specifiers" (e.g. "@foo/bar") resulting from a path through node_modules to a package.json's "types" entry + // 2. Specifiers generated using "paths" from tsconfig + // 3. Non-relative specfiers resulting from a path through node_modules (e.g. "@foo/bar/path/to/file") + // 4. Relative paths + var nodeModulesSpecifiers; + var pathsSpecifiers; + var relativeSpecifiers; + for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) { + var modulePath = modulePaths_1[_i]; + var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); + nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier); + if (specifier && modulePath.isRedirect) { + // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar", + // not "@foo/bar/path/to/file"). No other specifier will be this good, so stop looking. + return nodeModulesSpecifiers; + } + if (!specifier && !modulePath.isRedirect) { + var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences); + if (ts.pathIsBareSpecifier(local)) { + pathsSpecifiers = ts.append(pathsSpecifiers, local); + } + else if (!importedFileIsInNodeModules || modulePath.isInNodeModules) { + // Why this extra conditional, not just an `else`? If some path to the file contained + // 'node_modules', but we can't create a non-relative specifier (e.g. "@foo/bar/path/to/file"), + // that means we had to go through a *sibling's* node_modules, not one we can access directly. + // If some path to the file was in node_modules but another was not, this likely indicates that + // we have a monorepo structure with symlinks. In this case, the non-node_modules path is + // probably the realpath, e.g. "../bar/path/to/file", but a relative path to another package + // in a monorepo is probably not portable. So, the module specifier we actually go with will be + // the relative path through node_modules, so that the declaration emitter can produce a + // portability error. (See declarationEmitReexportedSymlinkReference3) + relativeSpecifiers = ts.append(relativeSpecifiers, local); + } + } + } + return (pathsSpecifiers === null || pathsSpecifiers === void 0 ? void 0 : pathsSpecifiers.length) ? pathsSpecifiers : + (nodeModulesSpecifiers === null || nodeModulesSpecifiers === void 0 ? void 0 : nodeModulesSpecifiers.length) ? nodeModulesSpecifiers : + ts.Debug.checkDefined(relativeSpecifiers); } moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers; // importingSourceFileName is separate because getEditsForFileRename may need to specify an updated path @@ -107757,22 +110251,26 @@ var ts; var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); return { getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory }; } - function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, _b) { + function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { return relativePath; } - var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); + var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl; + var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName); if (!relativeToBaseUrl) { return relativePath; } var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - var nonRelative = fromPaths === undefined ? importRelativeToBaseUrl : fromPaths; + var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; + if (!nonRelative) { + return relativePath; + } if (relativePreference === 1 /* NonRelative */) { return nonRelative; } @@ -107801,8 +110299,8 @@ var ts; var match = str.match(/\//g); return match ? match.length : 0; } - function comparePathsByNumberOfDirectorySeparators(a, b) { - return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); + function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) { + return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareValues(numberOfDirectorySeparators(a.path), numberOfDirectorySeparators(b.path)); } function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) { var getCanonicalFileName = ts.hostGetCanonicalFileName(host); @@ -107812,34 +110310,36 @@ var ts; var importedFileNames = __spreadArrays((referenceRedirect ? [referenceRedirect] : ts.emptyArray), [importedFileName], redirects); var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); if (!preferSymlinks) { - var result_13 = ts.forEach(targets, cb); - if (result_13) - return result_13; + var result_15 = ts.forEach(targets, function (p) { return cb(p, referenceRedirect === p); }); + if (result_15) + return result_15; } var links = host.getSymlinkCache ? host.getSymlinkCache() : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd); var symlinkedDirectories = links.getSymlinkedDirectories(); - var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; + var useCaseSensitiveFileNames = !host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames(); var result = symlinkedDirectories && ts.forEachEntry(symlinkedDirectories, function (resolved, path) { if (resolved === false) return undefined; if (ts.startsWithDirectory(importingFileName, resolved.realPath, getCanonicalFileName)) { return undefined; // Don't want to a package to globally import from itself } - var target = ts.find(targets, function (t) { return compareStrings(t.slice(0, resolved.real.length), resolved.real) === 0 /* EqualTo */; }); - if (target === undefined) - return undefined; - var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName); - var option = ts.resolvePath(path, relative); - if (!host.fileExists || host.fileExists(option)) { - var result_14 = cb(option); - if (result_14) - return result_14; - } + return ts.forEach(targets, function (target) { + if (!ts.containsPath(resolved.real, target, !useCaseSensitiveFileNames)) { + return; + } + var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName); + var option = ts.resolvePath(path, relative); + if (!host.fileExists || host.fileExists(option)) { + var result_16 = cb(option, target === referenceRedirect); + if (result_16) + return result_16; + } + }); }); return result || - (preferSymlinks ? ts.forEach(targets, cb) : undefined); + (preferSymlinks ? ts.forEach(targets, function (p) { return cb(p, p === referenceRedirect); }) : undefined); } moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule; /** @@ -107852,28 +110352,27 @@ var ts; var allFileNames = new ts.Map(); var importedFileFromNodeModules = false; forEachFileNameOfModule(importingFileName, importedFileName, host, - /*preferSymlinks*/ true, function (path) { - // dont return value, so we collect everything - allFileNames.set(path, getCanonicalFileName(path)); - importedFileFromNodeModules = importedFileFromNodeModules || ts.pathContainsNodeModules(path); + /*preferSymlinks*/ true, function (path, isRedirect) { + var isInNodeModules = ts.pathContainsNodeModules(path); + allFileNames.set(path, { path: getCanonicalFileName(path), isRedirect: isRedirect, isInNodeModules: isInNodeModules }); + importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules; + // don't return value, so we collect everything }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_23 = function (directory) { + var _loop_24 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; - allFileNames.forEach(function (canonicalFileName, fileName) { - if (ts.startsWith(canonicalFileName, directoryStart)) { - // If the importedFile is from node modules, use only paths in node_modules folder as option - if (!importedFileFromNodeModules || ts.pathContainsNodeModules(fileName)) { - (pathsInDirectory || (pathsInDirectory = [])).push(fileName); - } + allFileNames.forEach(function (_a, fileName) { + var path = _a.path, isRedirect = _a.isRedirect, isInNodeModules = _a.isInNodeModules; + if (ts.startsWith(path, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push({ path: fileName, isRedirect: isRedirect, isInNodeModules: isInNodeModules }); allFileNames.delete(fileName); } }); if (pathsInDirectory) { if (pathsInDirectory.length > 1) { - pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators); + pathsInDirectory.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); } sortedPaths.push.apply(sortedPaths, pathsInDirectory); } @@ -107885,7 +110384,7 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { - var state_8 = _loop_23(directory); + var state_8 = _loop_24(directory); directory = out_directory_1; if (state_8 === "break") break; @@ -107893,7 +110392,7 @@ var ts; if (allFileNames.size) { var remainingPaths = ts.arrayFrom(allFileNames.values()); if (remainingPaths.length > 1) - remainingPaths.sort(comparePathsByNumberOfDirectorySeparators); + remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); sortedPaths.push.apply(sortedPaths, remainingPaths); } return sortedPaths; @@ -107938,37 +110437,43 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { - var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; + function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) { + var path = _a.path, isRedirect = _a.isRedirect; + var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; } - var parts = getNodeModulePathParts(moduleFileName); + var parts = getNodeModulePathParts(path); if (!parts) { return undefined; } // Simplify the full file path to something that can be resolved by Node. - var moduleSpecifier = moduleFileName; + var moduleSpecifier = path; + var isPackageRootPath = false; if (!packageNameOnly) { var packageRootIndex = parts.packageRootIndex; var moduleFileNameForExtensionless = void 0; while (true) { // If the module could be imported by a directory name, use that directory's name - var _b = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _b.moduleFileToTry, packageRootPath = _b.packageRootPath; + var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath; if (packageRootPath) { moduleSpecifier = packageRootPath; + isPackageRootPath = true; break; } if (!moduleFileNameForExtensionless) moduleFileNameForExtensionless = moduleFileToTry; // try with next level of directory - packageRootIndex = moduleFileName.indexOf(ts.directorySeparator, packageRootIndex + 1); + packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless); break; } } } + if (isRedirect && !isPackageRootPath) { + return undefined; + } var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. @@ -107982,16 +110487,16 @@ var ts; // For classic resolution, only allow importing from node_modules/@types, not other node_modules return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName; function tryDirectoryWithPackageJson(packageRootIndex) { - var packageRootPath = moduleFileName.substring(0, packageRootIndex); + var packageRootPath = path.substring(0, packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var moduleFileToTry = moduleFileName; + var moduleFileToTry = path; if (host.fileExists(packageJsonPath)) { var packageJsonContent = JSON.parse(host.readFile(packageJsonPath)); var versionPaths = packageJsonContent.typesVersions ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) : undefined; if (versionPaths) { - var subModuleName = moduleFileName.slice(packageRootPath.length + 1); + var subModuleName = path.slice(packageRootPath.length + 1); var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); if (fromPaths !== undefined) { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); @@ -108395,7 +110900,7 @@ var ts; ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; function setGetSourceFileAsHashVersioned(compilerHost, host) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = host.createHash || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -108403,7 +110908,7 @@ var ts; } var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { - result.version = computeHash.call(host, result.text); + result.version = computeHash(result.text); } return result; }; @@ -108922,7 +111427,7 @@ var ts; } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); - var result = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost); + var result = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions); if (ts.updateErrorForNoInputFiles(result, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) { hasChangedConfigFileParsingErrors = true; } @@ -109008,6 +111513,7 @@ var ts; fileOrDirectoryPath: fileOrDirectoryPath, configFileName: configFileName, configFileSpecs: configFileSpecs, + extraFileExtensions: extraFileExtensions, options: compilerOptions, program: getCurrentBuilderProgram(), currentDirectory: currentDirectory, @@ -110596,7 +113102,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds(); + return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -110706,7 +113212,9 @@ var ts; var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); getTypingNamesFromPackagesFolder(nodeModulesPath, filesToWatch); }); - getTypingNamesFromSourceFileNames(fileNames); + if (!typeAcquisition.disableFilenameBasedTypeAcquisition) { + getTypingNamesFromSourceFileNames(fileNames); + } // add typings for unresolved imports if (unresolvedImports) { var module_1 = ts.deduplicate(unresolvedImports.map(nonRelativeModuleNameForTypingCache), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); @@ -110967,6 +113475,11 @@ var ts; })(LanguageServiceMode = ts.LanguageServiceMode || (ts.LanguageServiceMode = {})); /* @internal */ ts.emptyOptions = {}; + var SemanticClassificationFormat; + (function (SemanticClassificationFormat) { + SemanticClassificationFormat["Original"] = "original"; + SemanticClassificationFormat["TwentyTwenty"] = "2020"; + })(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {})); var HighlightSpanKind; (function (HighlightSpanKind) { HighlightSpanKind["none"] = "none"; @@ -111240,37 +113753,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 159 /* Parameter */: - case 195 /* BindingElement */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 285 /* PropertyAssignment */: - case 286 /* ShorthandPropertyAssignment */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 284 /* CatchClause */: - case 277 /* JsxAttribute */: + case 160 /* Parameter */: + case 198 /* BindingElement */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 288 /* PropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 287 /* CatchClause */: + case 280 /* JsxAttribute */: return 1 /* Value */; - case 158 /* TypeParameter */: - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 176 /* TypeLiteral */: + case 159 /* TypeParameter */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 177 /* TypeLiteral */: return 2 /* Type */; - case 327 /* JSDocTypedefTag */: + case 331 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 288 /* EnumMember */: - case 249 /* ClassDeclaration */: + case 291 /* EnumMember */: + case 252 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -111280,16 +113793,16 @@ var ts; else { return 4 /* Namespace */; } - case 252 /* EnumDeclaration */: - case 261 /* NamedImports */: - case 262 /* ImportSpecifier */: - case 257 /* ImportEqualsDeclaration */: - case 258 /* ImportDeclaration */: - case 263 /* ExportAssignment */: - case 264 /* ExportDeclaration */: + case 255 /* EnumDeclaration */: + case 264 /* NamedImports */: + case 265 /* ImportSpecifier */: + case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportDeclaration */: + case 266 /* ExportAssignment */: + case 267 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 294 /* SourceFile */: + case 297 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; @@ -111297,13 +113810,13 @@ var ts; ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); - if (node.kind === 294 /* SourceFile */) { + if (node.kind === 297 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 263 /* ExportAssignment */ - || node.parent.kind === 269 /* ExternalModuleReference */ - || node.parent.kind === 262 /* ImportSpecifier */ - || node.parent.kind === 259 /* ImportClause */ + else if (node.parent.kind === 266 /* ExportAssignment */ + || node.parent.kind === 272 /* ExternalModuleReference */ + || node.parent.kind === 265 /* ImportSpecifier */ + || node.parent.kind === 262 /* ImportClause */ || ts.isImportEqualsDeclaration(node.parent) && node === node.parent.name) { return 7 /* All */; } @@ -111313,6 +113826,9 @@ var ts; else if (ts.isDeclarationName(node)) { return getMeaningFromDeclaration(node.parent); } + else if (ts.isEntityName(node) && ts.isJSDocNameReference(node.parent)) { + return 7 /* All */; + } else if (isTypeReference(node)) { return 2 /* Type */; } @@ -111336,11 +113852,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 156 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 257 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 157 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 260 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 156 /* QualifiedName */) { + while (node.parent.kind === 157 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -111352,27 +113868,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 156 /* QualifiedName */) { - while (root.parent && root.parent.kind === 156 /* QualifiedName */) { + if (root.parent.kind === 157 /* QualifiedName */) { + while (root.parent && root.parent.kind === 157 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 172 /* TypeReference */ && !isLastClause; + return root.parent.kind === 173 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 198 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 198 /* PropertyAccessExpression */) { + if (root.parent.kind === 201 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 201 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 220 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 283 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 223 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 286 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 249 /* ClassDeclaration */ && root.parent.parent.token === 116 /* ImplementsKeyword */) || - (decl.kind === 250 /* InterfaceDeclaration */ && root.parent.parent.token === 93 /* ExtendsKeyword */); + return (decl.kind === 252 /* ClassDeclaration */ && root.parent.parent.token === 116 /* ImplementsKeyword */) || + (decl.kind === 253 /* InterfaceDeclaration */ && root.parent.parent.token === 93 /* ExtendsKeyword */); } return false; } @@ -111383,15 +113899,15 @@ var ts; switch (node.kind) { case 107 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 186 /* ThisType */: + case 187 /* ThisType */: return true; } switch (node.parent.kind) { - case 172 /* TypeReference */: + case 173 /* TypeReference */: return true; - case 192 /* ImportType */: + case 195 /* ImportType */: return !node.parent.isTypeOf; - case 220 /* ExpressionWithTypeArguments */: + case 223 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -111458,7 +113974,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 242 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 245 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -111519,22 +114035,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 285 /* PropertyAssignment */: - case 288 /* EnumMember */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 253 /* ModuleDeclaration */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 288 /* PropertyAssignment */: + case 291 /* EnumMember */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 256 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 157 /* ComputedPropertyName */: + case 158 /* ComputedPropertyName */: return true; - case 190 /* LiteralType */: - return node.parent.parent.kind === 188 /* IndexedAccessType */; + case 191 /* LiteralType */: + return node.parent.parent.kind === 189 /* IndexedAccessType */; default: return false; } @@ -111558,17 +114074,17 @@ var ts; return undefined; } switch (node.kind) { - case 294 /* SourceFile */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: - case 253 /* ModuleDeclaration */: + case 297 /* SourceFile */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: + case 256 /* ModuleDeclaration */: return node; } } @@ -111576,54 +114092,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 294 /* SourceFile */: + case 297 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: return "class" /* classElement */; - case 250 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 251 /* TypeAliasDeclaration */: - case 320 /* JSDocCallbackTag */: - case 327 /* JSDocTypedefTag */: + case 253 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 254 /* TypeAliasDeclaration */: + case 324 /* JSDocCallbackTag */: + case 331 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 252 /* EnumDeclaration */: return "enum" /* enumElement */; - case 246 /* VariableDeclaration */: + case 255 /* EnumDeclaration */: return "enum" /* enumElement */; + case 249 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 195 /* BindingElement */: + case 198 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 206 /* ArrowFunction */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: return "function" /* functionElement */; - case 166 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 167 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 167 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 168 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: var initializer = node.initializer; return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 286 /* ShorthandPropertyAssignment */: - case 287 /* SpreadAssignment */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 289 /* ShorthandPropertyAssignment */: + case 290 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 170 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 169 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 168 /* CallSignature */: return "call" /* callSignatureElement */; - case 165 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 158 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 288 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 159 /* Parameter */: return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 257 /* ImportEqualsDeclaration */: - case 262 /* ImportSpecifier */: - case 267 /* ExportSpecifier */: - case 260 /* NamespaceImport */: - case 266 /* NamespaceExport */: + case 171 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 170 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 169 /* CallSignature */: return "call" /* callSignatureElement */; + case 166 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 159 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 291 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 160 /* Parameter */: return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 260 /* ImportEqualsDeclaration */: + case 265 /* ImportSpecifier */: + case 270 /* ExportSpecifier */: + case 263 /* NamespaceImport */: + case 269 /* NamespaceExport */: return "alias" /* alias */; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -111652,7 +114168,7 @@ var ts; } case 78 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; @@ -111675,7 +114191,7 @@ var ts; return true; case 78 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 159 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 160 /* Parameter */; default: return false; } @@ -111740,42 +114256,42 @@ var ts; return false; } switch (n.kind) { - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: - case 197 /* ObjectLiteralExpression */: - case 193 /* ObjectBindingPattern */: - case 176 /* TypeLiteral */: - case 227 /* Block */: - case 254 /* ModuleBlock */: - case 255 /* CaseBlock */: - case 261 /* NamedImports */: - case 265 /* NamedExports */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: + case 200 /* ObjectLiteralExpression */: + case 196 /* ObjectBindingPattern */: + case 177 /* TypeLiteral */: + case 230 /* Block */: + case 257 /* ModuleBlock */: + case 258 /* CaseBlock */: + case 264 /* NamedImports */: + case 268 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 201 /* NewExpression */: + case 204 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 200 /* CallExpression */: - case 204 /* ParenthesizedExpression */: - case 185 /* ParenthesizedType */: + case 203 /* CallExpression */: + case 207 /* ParenthesizedExpression */: + case 186 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 173 /* FunctionType */: - case 174 /* ConstructorType */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 169 /* ConstructSignature */: - case 168 /* CallSignature */: - case 206 /* ArrowFunction */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 170 /* ConstructSignature */: + case 169 /* CallSignature */: + case 209 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -111785,65 +114301,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 231 /* IfStatement */: + case 234 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 196 /* ArrayLiteralExpression */: - case 194 /* ArrayBindingPattern */: - case 199 /* ElementAccessExpression */: - case 157 /* ComputedPropertyName */: - case 178 /* TupleType */: + case 199 /* ArrayLiteralExpression */: + case 197 /* ArrayBindingPattern */: + case 202 /* ElementAccessExpression */: + case 158 /* ComputedPropertyName */: + case 179 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 170 /* IndexSignature */: + case 171 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 281 /* CaseClause */: - case 282 /* DefaultClause */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 233 /* WhileStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 236 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 232 /* DoStatement */: + case 235 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 114 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 175 /* TypeQuery */: + case 176 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 208 /* TypeOfExpression */: - case 207 /* DeleteExpression */: - case 209 /* VoidExpression */: - case 216 /* YieldExpression */: - case 217 /* SpreadElement */: + case 211 /* TypeOfExpression */: + case 210 /* DeleteExpression */: + case 212 /* VoidExpression */: + case 219 /* YieldExpression */: + case 220 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 215 /* TemplateExpression */: + case 218 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 225 /* TemplateSpan */: + case 228 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 264 /* ExportDeclaration */: - case 258 /* ImportDeclaration */: + case 267 /* ExportDeclaration */: + case 261 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 214 /* ConditionalExpression */: + case 217 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -111950,11 +114466,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: return getAdjustedLocationForClass(node); - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -112049,11 +114565,11 @@ var ts; node.kind === 97 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : node.kind === 117 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : node.kind === 91 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 148 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 139 /* NamespaceKeyword */ || node.kind === 138 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 149 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 140 /* NamespaceKeyword */ || node.kind === 139 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : node.kind === 99 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : node.kind === 134 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 145 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + node.kind === 146 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; @@ -112067,7 +114583,7 @@ var ts; return decl.name; } } - if (node.kind === 148 /* TypeKeyword */) { + if (node.kind === 149 /* TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -112134,12 +114650,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 142 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 143 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 152 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 153 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -112172,12 +114688,12 @@ var ts; return parent.name; } // /**/keyof [|T|] - if (node.kind === 137 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 137 /* KeyOfKeyword */ && + if (node.kind === 138 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 138 /* KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 141 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 141 /* ReadonlyKeyword */ && + if (node.kind === 142 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 142 /* ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -112214,7 +114730,7 @@ var ts; // for (... /**/in [|name|]) // for (... /**/of [|name|]) if (node.kind === 100 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 155 /* OfKeyword */ && ts.isForOfStatement(parent)) { + node.kind === 156 /* OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -112332,7 +114848,21 @@ var ts; return n; } var children = n.getChildren(sourceFile); - for (var i = 0; i < children.length; i++) { + var i = ts.binarySearchKey(children, position, function (_, i) { return i; }, function (middle, _) { + // This last callback is more of a selector than a comparator - + // `EqualTo` causes the `middle` result to be returned + // `GreaterThan` causes recursion on the left of the middle + // `LessThan` causes recursion on the right of the middle + if (position < children[middle].end) { + // first element whose end position is greater than the input position + if (!children[middle - 1] || position >= children[middle - 1].end) { + return 0 /* EqualTo */; + } + return 1 /* GreaterThan */; + } + return -1 /* LessThan */; + }); + if (i >= 0 && children[i]) { var child = children[i]; // Note that the span of a node's tokens is [node.getStart(...), node.end). // Given that `position < child.end` and child has constituent tokens, we distinguish these cases: @@ -112355,7 +114885,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 294 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 297 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -112373,6 +114903,9 @@ var ts; return n; } var children = n.getChildren(sourceFile); + if (children.length === 0) { + return n; + } var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); return candidate && findRightmostToken(candidate, sourceFile); } @@ -112425,17 +114958,17 @@ var ts; return true; } // <div> { | </div> or <div a={| </div> - if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 280 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 283 /* JsxExpression */) { return true; } // <div> { // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 280 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 283 /* JsxExpression */) { return true; } // <div>|</div> - if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 273 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 276 /* JsxClosingElement */) { return true; } return false; @@ -112466,7 +114999,7 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 271 /* JsxSelfClosingElement */ && node.kind <= 280 /* JsxExpression */ + if (node.kind >= 274 /* JsxSelfClosingElement */ && node.kind <= 283 /* JsxExpression */ || node.kind === 11 /* JsxText */ || node.kind === 29 /* LessThanToken */ || node.kind === 31 /* GreaterThanToken */ @@ -112476,7 +115009,7 @@ var ts; || node.kind === 43 /* SlashToken */) { node = node.parent; } - else if (node.kind === 270 /* JsxElement */) { + else if (node.kind === 273 /* JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -112603,7 +115136,7 @@ var ts; // falls through case 111 /* TypeOfKeyword */: case 93 /* ExtendsKeyword */: - case 137 /* KeyOfKeyword */: + case 138 /* KeyOfKeyword */: case 24 /* DotToken */: case 51 /* BarToken */: case 57 /* QuestionToken */: @@ -112660,16 +115193,16 @@ var ts; result.push("deprecated" /* deprecatedModifier */); if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); - if (node.kind === 263 /* ExportAssignment */) + if (node.kind === 266 /* ExportAssignment */) result.push("export" /* exportedModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 172 /* TypeReference */ || node.kind === 200 /* CallExpression */) { + if (node.kind === 173 /* TypeReference */ || node.kind === 203 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 249 /* ClassDeclaration */ || node.kind === 250 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 252 /* ClassDeclaration */ || node.kind === 253 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -112714,18 +115247,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 196 /* ArrayLiteralExpression */ || - node.kind === 197 /* ObjectLiteralExpression */) { + if (node.kind === 199 /* ArrayLiteralExpression */ || + node.kind === 200 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 213 /* BinaryExpression */ && + if (node.parent.kind === 216 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 236 /* ForOfStatement */ && + if (node.parent.kind === 239 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -112733,7 +115266,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 285 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 288 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -112797,29 +115330,29 @@ var ts; ts.typeKeywords = [ 128 /* AnyKeyword */, 127 /* AssertsKeyword */, - 154 /* BigIntKeyword */, + 155 /* BigIntKeyword */, 131 /* BooleanKeyword */, 94 /* FalseKeyword */, - 137 /* KeyOfKeyword */, - 140 /* NeverKeyword */, + 138 /* KeyOfKeyword */, + 141 /* NeverKeyword */, 103 /* NullKeyword */, - 143 /* NumberKeyword */, - 144 /* ObjectKeyword */, - 141 /* ReadonlyKeyword */, - 146 /* StringKeyword */, - 147 /* SymbolKeyword */, + 144 /* NumberKeyword */, + 145 /* ObjectKeyword */, + 142 /* ReadonlyKeyword */, + 147 /* StringKeyword */, + 148 /* SymbolKeyword */, 109 /* TrueKeyword */, 113 /* VoidKeyword */, - 149 /* UndefinedKeyword */, - 150 /* UniqueKeyword */, - 151 /* UnknownKeyword */, + 150 /* UndefinedKeyword */, + 151 /* UniqueKeyword */, + 152 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 148 /* TypeKeyword */; + return node.kind === 149 /* TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; /** True if the symbol is for an external module, as opposed to a namespace. */ @@ -112852,7 +115385,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 157 /* ComputedPropertyName */ + return name.kind === 158 /* ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -112883,7 +115416,7 @@ var ts; getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); }, - isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); }, + isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); } }; } ts.createModuleSpecifierResolutionHost = createModuleSpecifierResolutionHost; @@ -112921,7 +115454,9 @@ var ts; return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; } else { - var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, ts.isStringLiteral); + // ignore synthetic import added when importHelpers: true + var firstModuleSpecifier = sourceFile.imports && + ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); }); return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; } } @@ -113013,7 +115548,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 229 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 232 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -113091,7 +115626,7 @@ var ts; // Display-part writer helpers // #region function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 159 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 160 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -113372,36 +115907,22 @@ var ts; return clone; } ts.getSynthesizedDeepClone = getSynthesizedDeepClone; - function getSynthesizedDeepCloneWithRenames(node, includeTrivia, renameMap, checker, callback) { - if (includeTrivia === void 0) { includeTrivia = true; } - var clone; - if (renameMap && checker && ts.isBindingElement(node) && ts.isIdentifier(node.name) && ts.isObjectBindingPattern(node.parent)) { - var symbol = checker.getSymbolAtLocation(node.name); - var renameInfo = symbol && renameMap.get(String(ts.getSymbolId(symbol))); - if (renameInfo && renameInfo.text !== (node.name || node.propertyName).getText()) { - clone = ts.setOriginalNode(ts.factory.createBindingElement(node.dotDotDotToken, node.propertyName || node.name, renameInfo, node.initializer), node); - } - } - else if (renameMap && checker && ts.isIdentifier(node)) { - var symbol = checker.getSymbolAtLocation(node); - var renameInfo = symbol && renameMap.get(String(ts.getSymbolId(symbol))); - if (renameInfo) { - clone = ts.setOriginalNode(ts.factory.createIdentifier(renameInfo.text), node); - } + function getSynthesizedDeepCloneWithReplacements(node, includeTrivia, replaceNode) { + var clone = replaceNode(node); + if (clone) { + ts.setOriginalNode(clone, node); } - if (!clone) { - clone = getSynthesizedDeepCloneWorker(node, renameMap, checker, callback); + else { + clone = getSynthesizedDeepCloneWorker(node, replaceNode); } if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone); - if (callback && clone) - callback(node, clone); return clone; } - ts.getSynthesizedDeepCloneWithRenames = getSynthesizedDeepCloneWithRenames; - function getSynthesizedDeepCloneWorker(node, renameMap, checker, callback) { - var visited = (renameMap || checker || callback) ? - ts.visitEachChild(node, wrapper, ts.nullTransformationContext) : + ts.getSynthesizedDeepCloneWithReplacements = getSynthesizedDeepCloneWithReplacements; + function getSynthesizedDeepCloneWorker(node, replaceNode) { + var visited = replaceNode ? + ts.visitEachChild(node, function (n) { return getSynthesizedDeepCloneWithReplacements(n, /*includeTrivia*/ true, replaceNode); }, ts.nullTransformationContext) : ts.visitEachChild(node, getSynthesizedDeepClone, ts.nullTransformationContext); if (visited === node) { // This only happens for leaf nodes - internal nodes always see their children change. @@ -113415,15 +115936,16 @@ var ts; // would have made. visited.parent = undefined; return visited; - function wrapper(node) { - return getSynthesizedDeepCloneWithRenames(node, /*includeTrivia*/ true, renameMap, checker, callback); - } } function getSynthesizedDeepClones(nodes, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = true; } return nodes && ts.factory.createNodeArray(nodes.map(function (n) { return getSynthesizedDeepClone(n, includeTrivia); }), nodes.hasTrailingComma); } ts.getSynthesizedDeepClones = getSynthesizedDeepClones; + function getSynthesizedDeepClonesWithReplacements(nodes, includeTrivia, replaceNode) { + return ts.factory.createNodeArray(nodes.map(function (n) { return getSynthesizedDeepCloneWithReplacements(n, includeTrivia, replaceNode); }), nodes.hasTrailingComma); + } + ts.getSynthesizedDeepClonesWithReplacements = getSynthesizedDeepClonesWithReplacements; /** * Sets EmitFlags to suppress leading and trailing trivia on the node. */ @@ -113568,35 +116090,26 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 201 /* NewExpression */: + case 204 /* NewExpression */: return checker.getContextualType(parent); - case 213 /* BinaryExpression */: { + case 216 /* BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 281 /* CaseClause */: + case 284 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); } } ts.getContextualTypeFromParent = getContextualTypeFromParent; - function quote(text, preferences) { + function quote(sourceFile, preferences, text) { // Editors can pass in undefined or empty string - we want to infer the preference in those cases. - var quotePreference = preferences.quotePreference || "auto"; + var quotePreference = getQuotePreference(sourceFile, preferences); var quoted = JSON.stringify(text); - switch (quotePreference) { - // TODO use getQuotePreference to infer the actual quote style. - case "auto": - case "double": - return quoted; - case "single": - return "'" + ts.stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'"; - default: - return ts.Debug.assertNever(quotePreference); - } + return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'" : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { @@ -113615,8 +116128,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 215 /* TemplateExpression */: - case 202 /* TaggedTemplateExpression */: + case 218 /* TemplateExpression */: + case 205 /* TaggedTemplateExpression */: return true; default: return false; @@ -113636,7 +116149,7 @@ var ts; var checker = program.getTypeChecker(); var typeIsAccessible = true; var notAccessible = function () { typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { + var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; }, @@ -113649,41 +116162,41 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 168 /* CallSignature */ - || kind === 169 /* ConstructSignature */ - || kind === 170 /* IndexSignature */ - || kind === 161 /* PropertySignature */ - || kind === 163 /* MethodSignature */; + return kind === 169 /* CallSignature */ + || kind === 170 /* ConstructSignature */ + || kind === 171 /* IndexSignature */ + || kind === 162 /* PropertySignature */ + || kind === 164 /* MethodSignature */; } ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 248 /* FunctionDeclaration */ - || kind === 165 /* Constructor */ - || kind === 164 /* MethodDeclaration */ - || kind === 166 /* GetAccessor */ - || kind === 167 /* SetAccessor */; + return kind === 251 /* FunctionDeclaration */ + || kind === 166 /* Constructor */ + || kind === 165 /* MethodDeclaration */ + || kind === 167 /* GetAccessor */ + || kind === 168 /* SetAccessor */; } ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 253 /* ModuleDeclaration */; + return kind === 256 /* ModuleDeclaration */; } ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 229 /* VariableStatement */ - || kind === 230 /* ExpressionStatement */ - || kind === 232 /* DoStatement */ - || kind === 237 /* ContinueStatement */ - || kind === 238 /* BreakStatement */ - || kind === 239 /* ReturnStatement */ - || kind === 243 /* ThrowStatement */ - || kind === 245 /* DebuggerStatement */ - || kind === 162 /* PropertyDeclaration */ - || kind === 251 /* TypeAliasDeclaration */ - || kind === 258 /* ImportDeclaration */ - || kind === 257 /* ImportEqualsDeclaration */ - || kind === 264 /* ExportDeclaration */ - || kind === 256 /* NamespaceExportDeclaration */ - || kind === 263 /* ExportAssignment */; + return kind === 232 /* VariableStatement */ + || kind === 233 /* ExpressionStatement */ + || kind === 235 /* DoStatement */ + || kind === 240 /* ContinueStatement */ + || kind === 241 /* BreakStatement */ + || kind === 242 /* ReturnStatement */ + || kind === 246 /* ThrowStatement */ + || kind === 248 /* DebuggerStatement */ + || kind === 163 /* PropertyDeclaration */ + || kind === 254 /* TypeAliasDeclaration */ + || kind === 261 /* ImportDeclaration */ + || kind === 260 /* ImportEqualsDeclaration */ + || kind === 267 /* ExportDeclaration */ + || kind === 259 /* NamespaceExportDeclaration */ + || kind === 266 /* ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); @@ -113713,7 +116226,7 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 232 /* DoStatement */) { + if (node.kind === 235 /* DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); @@ -114132,10 +116645,10 @@ var ts; } break; case 128 /* AnyKeyword */: - case 146 /* StringKeyword */: - case 143 /* NumberKeyword */: + case 147 /* StringKeyword */: + case 144 /* NumberKeyword */: case 131 /* BooleanKeyword */: - case 147 /* SymbolKeyword */: + case 148 /* SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -114325,7 +116838,7 @@ var ts; } switch (keyword2) { case 134 /* GetKeyword */: - case 145 /* SetKeyword */: + case 146 /* SetKeyword */: case 132 /* ConstructorKeyword */: case 123 /* StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". @@ -114470,13 +116983,13 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 253 /* ModuleDeclaration */: - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 248 /* FunctionDeclaration */: - case 218 /* ClassExpression */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 256 /* ModuleDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 251 /* FunctionDeclaration */: + case 221 /* ClassExpression */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -114696,18 +117209,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 322 /* JSDocParameterTag */: + case 326 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 326 /* JSDocTemplateTag */: + case 330 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 325 /* JSDocTypeTag */: + case 329 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 323 /* JSDocReturnTag */: + case 327 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -114858,22 +117371,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 272 /* JsxOpeningElement */: + case 275 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 273 /* JsxClosingElement */: + case 276 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 271 /* JsxSelfClosingElement */: + case 274 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 277 /* JsxAttribute */: + case 280 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -114902,17 +117415,17 @@ var ts; var parent = token.parent; if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 246 /* VariableDeclaration */ || - parent.kind === 162 /* PropertyDeclaration */ || - parent.kind === 159 /* Parameter */ || - parent.kind === 277 /* JsxAttribute */) { + if (parent.kind === 249 /* VariableDeclaration */ || + parent.kind === 163 /* PropertyDeclaration */ || + parent.kind === 160 /* Parameter */ || + parent.kind === 280 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 213 /* BinaryExpression */ || - parent.kind === 211 /* PrefixUnaryExpression */ || - parent.kind === 212 /* PostfixUnaryExpression */ || - parent.kind === 214 /* ConditionalExpression */) { + if (parent.kind === 216 /* BinaryExpression */ || + parent.kind === 214 /* PrefixUnaryExpression */ || + parent.kind === 215 /* PostfixUnaryExpression */ || + parent.kind === 217 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -114925,7 +117438,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 277 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 280 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -114941,32 +117454,32 @@ var ts; else if (tokenKind === 78 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 159 /* Parameter */: + case 160 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -114995,6 +117508,254 @@ var ts; } ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); +/** @internal */ +var ts; +(function (ts) { + var classifier; + (function (classifier) { + var v2020; + (function (v2020) { + var TokenEncodingConsts; + (function (TokenEncodingConsts) { + TokenEncodingConsts[TokenEncodingConsts["typeOffset"] = 8] = "typeOffset"; + TokenEncodingConsts[TokenEncodingConsts["modifierMask"] = 255] = "modifierMask"; + })(TokenEncodingConsts = v2020.TokenEncodingConsts || (v2020.TokenEncodingConsts = {})); + var TokenType; + (function (TokenType) { + TokenType[TokenType["class"] = 0] = "class"; + TokenType[TokenType["enum"] = 1] = "enum"; + TokenType[TokenType["interface"] = 2] = "interface"; + TokenType[TokenType["namespace"] = 3] = "namespace"; + TokenType[TokenType["typeParameter"] = 4] = "typeParameter"; + TokenType[TokenType["type"] = 5] = "type"; + TokenType[TokenType["parameter"] = 6] = "parameter"; + TokenType[TokenType["variable"] = 7] = "variable"; + TokenType[TokenType["enumMember"] = 8] = "enumMember"; + TokenType[TokenType["property"] = 9] = "property"; + TokenType[TokenType["function"] = 10] = "function"; + TokenType[TokenType["member"] = 11] = "member"; + })(TokenType = v2020.TokenType || (v2020.TokenType = {})); + var TokenModifier; + (function (TokenModifier) { + TokenModifier[TokenModifier["declaration"] = 0] = "declaration"; + TokenModifier[TokenModifier["static"] = 1] = "static"; + TokenModifier[TokenModifier["async"] = 2] = "async"; + TokenModifier[TokenModifier["readonly"] = 3] = "readonly"; + TokenModifier[TokenModifier["defaultLibrary"] = 4] = "defaultLibrary"; + TokenModifier[TokenModifier["local"] = 5] = "local"; + })(TokenModifier = v2020.TokenModifier || (v2020.TokenModifier = {})); + /** This is mainly used internally for testing */ + function getSemanticClassifications(program, cancellationToken, sourceFile, span) { + var classifications = getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span); + ts.Debug.assert(classifications.spans.length % 3 === 0); + var dense = classifications.spans; + var result = []; + for (var i = 0; i < dense.length; i += 3) { + result.push({ + textSpan: ts.createTextSpan(dense[i], dense[i + 1]), + classificationType: dense[i + 2] + }); + } + return result; + } + v2020.getSemanticClassifications = getSemanticClassifications; + function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) { + return { + spans: getSemanticTokens(program, sourceFile, span, cancellationToken), + endOfLineState: 0 /* None */ + }; + } + v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications; + function getSemanticTokens(program, sourceFile, span, cancellationToken) { + var resultTokens = []; + var collector = function (node, typeIdx, modifierSet) { + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet); + }; + if (program && sourceFile) { + collectTokens(program, sourceFile, span, collector, cancellationToken); + } + return resultTokens; + } + function collectTokens(program, sourceFile, span, collector, cancellationToken) { + var typeChecker = program.getTypeChecker(); + var inJSXElement = false; + function visit(node) { + switch (node.kind) { + case 256 /* ModuleDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 251 /* FunctionDeclaration */: + case 221 /* ClassExpression */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { + return; + } + var prevInJSXElement = inJSXElement; + if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) { + inJSXElement = true; + } + if (ts.isJsxExpression(node)) { + inJSXElement = false; + } + if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node)) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + if (symbol.flags & 2097152 /* Alias */) { + symbol = typeChecker.getAliasedSymbol(symbol); + } + var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); + if (typeIdx !== undefined) { + var modifierSet = 0; + if (node.parent) { + var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); + if (parentIsDeclaration && node.parent.name === node) { + modifierSet = 1 << 0 /* declaration */; + } + } + // property declaration in constructor + if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { + typeIdx = 9 /* property */; + } + typeIdx = reclassifyByType(typeChecker, node, typeIdx); + var decl = symbol.valueDeclaration; + if (decl) { + var modifiers = ts.getCombinedModifierFlags(decl); + var nodeFlags = ts.getCombinedNodeFlags(decl); + if (modifiers & 32 /* Static */) { + modifierSet |= 1 << 1 /* static */; + } + if (modifiers & 256 /* Async */) { + modifierSet |= 1 << 2 /* async */; + } + if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { + if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) { + modifierSet |= 1 << 3 /* readonly */; + } + } + if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) { + modifierSet |= 1 << 5 /* local */; + } + if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) { + modifierSet |= 1 << 4 /* defaultLibrary */; + } + } + else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) { + modifierSet |= 1 << 4 /* defaultLibrary */; + } + collector(node, typeIdx, modifierSet); + } + } + } + ts.forEachChild(node, visit); + inJSXElement = prevInJSXElement; + } + visit(sourceFile); + } + function classifySymbol(symbol, meaning) { + var flags = symbol.getFlags(); + if (flags & 32 /* Class */) { + return 0 /* class */; + } + else if (flags & 384 /* Enum */) { + return 1 /* enum */; + } + else if (flags & 524288 /* TypeAlias */) { + return 5 /* type */; + } + else if (flags & 64 /* Interface */) { + if (meaning & 2 /* Type */) { + return 2 /* interface */; + } + } + else if (flags & 262144 /* TypeParameter */) { + return 4 /* typeParameter */; + } + var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; + if (decl && ts.isBindingElement(decl)) { + decl = getDeclarationForBindingElement(decl); + } + return decl && tokenFromDeclarationMapping.get(decl.kind); + } + function reclassifyByType(typeChecker, node, typeIdx) { + // type based classifications + if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) { + var type_1 = typeChecker.getTypeAtLocation(node); + if (type_1) { + var test = function (condition) { + return condition(type_1) || type_1.isUnion() && type_1.types.some(condition); + }; + if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { + return 0 /* class */; + } + if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) { + return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */; + } + } + } + return typeIdx; + } + function isLocalDeclaration(decl, sourceFile) { + if (ts.isBindingElement(decl)) { + decl = getDeclarationForBindingElement(decl); + } + if (ts.isVariableDeclaration(decl)) { + return (!ts.isSourceFile(decl.parent.parent.parent) || ts.isCatchClause(decl.parent)) && decl.getSourceFile() === sourceFile; + } + else if (ts.isFunctionDeclaration(decl)) { + return !ts.isSourceFile(decl.parent) && decl.getSourceFile() === sourceFile; + } + return false; + } + function getDeclarationForBindingElement(element) { + while (true) { + if (ts.isBindingElement(element.parent.parent)) { + element = element.parent.parent; + } + else { + return element.parent.parent; + } + } + } + function inImportClause(node) { + var parent = node.parent; + return parent && (ts.isImportClause(parent) || ts.isImportSpecifier(parent) || ts.isNamespaceImport(parent)); + } + function isExpressionInCallExpression(node) { + while (isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + return ts.isCallExpression(node.parent) && node.parent.expression === node; + } + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); + } + var tokenFromDeclarationMapping = new ts.Map([ + [249 /* VariableDeclaration */, 7 /* variable */], + [160 /* Parameter */, 6 /* parameter */], + [163 /* PropertyDeclaration */, 9 /* property */], + [256 /* ModuleDeclaration */, 3 /* namespace */], + [255 /* EnumDeclaration */, 1 /* enum */], + [291 /* EnumMember */, 8 /* enumMember */], + [252 /* ClassDeclaration */, 0 /* class */], + [165 /* MethodDeclaration */, 11 /* member */], + [251 /* FunctionDeclaration */, 10 /* function */], + [208 /* FunctionExpression */, 10 /* function */], + [164 /* MethodSignature */, 11 /* member */], + [167 /* GetAccessor */, 9 /* property */], + [168 /* SetAccessor */, 9 /* property */], + [162 /* PropertySignature */, 9 /* property */], + [253 /* InterfaceDeclaration */, 2 /* interface */], + [254 /* TypeAliasDeclaration */, 5 /* type */], + [159 /* TypeParameter */, 4 /* typeParameter */], + [288 /* PropertyAssignment */, 9 /* property */], + [289 /* ShorthandPropertyAssignment */, 9 /* property */] + ]); + })(v2020 = classifier.v2020 || (classifier.v2020 = {})); + })(classifier = ts.classifier || (ts.classifier = {})); +})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -115019,23 +117780,24 @@ var ts; if (completion === undefined) { return undefined; } + var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken); switch (completion.kind) { case 0 /* Paths */: return convertPathCompletions(completion.paths); case 1 /* Properties */: { var entries = []; Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } case 2 /* Types */: { var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, - sortText: "0", + sortText: Completions.SortText.LocationPriority, replacementSpan: ts.getReplacementSpanForContextToken(contextToken) }); }); - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } default: return ts.Debug.assertNever(completion); @@ -115094,33 +117856,46 @@ var ts; StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { - var parent = node.parent; + var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 190 /* LiteralType */: - switch (parent.parent.kind) { - case 172 /* TypeReference */: - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 188 /* IndexedAccessType */: + case 191 /* LiteralType */: { + var grandParent = walkUpParentheses(parent.parent); + switch (grandParent.kind) { + case 173 /* TypeReference */: { + var typeReference_1 = grandParent; + var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); + if (typeArgument) { + return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; + } + return undefined; + } + case 189 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; // bar: string; // } // let x: Foo["/*completion position*/"] - return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 192 /* ImportType */: + var _a = grandParent, indexType = _a.indexType, objectType = _a.objectType; + if (!ts.rangeContainsPosition(indexType, position)) { + return undefined; + } + return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); + case 195 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 181 /* UnionType */: { - if (!ts.isTypeReferenceNode(parent.parent.parent)) + case 182 /* UnionType */: { + if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; - var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); - var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent.parent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); + } + var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent); + var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; } default: return undefined; } - case 285 /* PropertyAssignment */: + } + case 288 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -115137,9 +117912,9 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 199 /* ElementAccessExpression */: { - var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; - if (node === argumentExpression) { + case 202 /* ElementAccessExpression */: { + var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; + if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression // i.e. interface A { // 'prop1': string @@ -115150,8 +117925,8 @@ var ts; } return undefined; } - case 200 /* CallExpression */: - case 201 /* NewExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -115160,9 +117935,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 258 /* ImportDeclaration */: - case 264 /* ExportDeclaration */: - case 269 /* ExternalModuleReference */: + case 261 /* ImportDeclaration */: + case 267 /* ExportDeclaration */: + case 272 /* ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); @@ -115179,6 +117954,16 @@ var ts; return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; } } + function walkUpParentheses(node) { + switch (node.kind) { + case 186 /* ParenthesizedType */: + return ts.walkUpParenthesizedTypes(node); + case 207 /* ParenthesizedExpression */: + return ts.walkUpParenthesizedExpressions(node); + default: + return node; + } + } function getAlreadyUsedTypesInStringLiteralUnion(union, current) { return ts.mapDefined(union.types, function (type) { return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined; @@ -115625,13 +118410,14 @@ var ts; (function (Completions) { var SortText; (function (SortText) { - SortText["LocationPriority"] = "0"; - SortText["OptionalMember"] = "1"; - SortText["MemberDeclaredBySpreadAssignment"] = "2"; - SortText["SuggestedClassMembers"] = "3"; - SortText["GlobalsOrKeywords"] = "4"; - SortText["AutoImportSuggestions"] = "5"; - SortText["JavascriptIdentifiers"] = "6"; + SortText["LocalDeclarationPriority"] = "0"; + SortText["LocationPriority"] = "1"; + SortText["OptionalMember"] = "2"; + SortText["MemberDeclaredBySpreadAssignment"] = "3"; + SortText["SuggestedClassMembers"] = "4"; + SortText["GlobalsOrKeywords"] = "5"; + SortText["AutoImportSuggestions"] = "6"; + SortText["JavascriptIdentifiers"] = "7"; })(SortText = Completions.SortText || (Completions.SortText = {})); /** * Special values for `CompletionInfo['source']` used to disambiguate @@ -115778,6 +118564,10 @@ var ts; function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } + function getOptionalReplacementSpan(location) { + // StringLiteralLike locations are handled separately in stringCompletions.ts + return (location === null || location === void 0 ? void 0 : location.kind) === 78 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + } 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, symbolToSortTextMap = completionData.symbolToSortTextMap; if (location && location.parent && ts.isJsxClosingElement(location.parent)) { @@ -115795,7 +118585,7 @@ var ts; kindModifiers: undefined, sortText: SortText.LocationPriority, }; - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [entry] }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: getOptionalReplacementSpan(location), entries: [entry] }; } var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { @@ -115821,9 +118611,15 @@ var ts; } for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) { var literal = literals_1[_b]; - entries.push(createCompletionEntryForLiteral(literal, preferences)); + entries.push(createCompletionEntryForLiteral(sourceFile, preferences, literal)); } - return { isGlobalCompletion: isInSnippetScope, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + return { + isGlobalCompletion: isInSnippetScope, + isMemberCompletion: isMemberCompletionKind(completionKind), + isNewIdentifierLocation: isNewIdentifierLocation, + optionalReplacementSpan: getOptionalReplacementSpan(location), + entries: entries + }; } function isUncheckedFile(sourceFile, compilerOptions) { return ts.isSourceFileJS(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); @@ -115857,12 +118653,12 @@ var ts; } }); } - function completionNameForLiteral(literal, preferences) { + function completionNameForLiteral(sourceFile, preferences, literal) { return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : - ts.isString(literal) ? ts.quote(literal, preferences) : JSON.stringify(literal); + ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal); } - function createCompletionEntryForLiteral(literal, preferences) { - return { name: completionNameForLiteral(literal, preferences), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; + function createCompletionEntryForLiteral(sourceFile, preferences, literal) { + return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; @@ -115871,13 +118667,13 @@ var ts; var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(name, preferences) + "]" + ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "this" + (insertQuestionDot ? "?." : ".") + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(name, preferences) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "[" + name + "]" : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { insertText = "?." + insertText; } @@ -115933,11 +118729,11 @@ var ts; isPackageJsonImport: originIsPackageJsonImport(origin) || undefined, }; } - function quotePropertyName(name, preferences) { + function quotePropertyName(sourceFile, preferences, name) { if (/^\d+$/.test(name)) { return name; } - return ts.quote(name, preferences); + return ts.quote(sourceFile, preferences, name); } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || @@ -116028,7 +118824,7 @@ var ts; return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; - var literal = ts.find(literals, function (l) { return completionNameForLiteral(l, preferences) === entryId.name; }); + var literal = ts.find(literals, function (l) { return completionNameForLiteral(sourceFile, preferences, l) === entryId.name; }); if (literal !== undefined) return { type: "literal", literal: literal }; // Find the symbol with the matching entry name. @@ -116074,7 +118870,7 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(literal, preferences), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. @@ -116146,11 +118942,11 @@ var ts; return ts.getContextualTypeFromParent(previousToken, checker); case 62 /* EqualsToken */: switch (parent.kind) { - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 277 /* JsxAttribute */: + case 280 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -116160,7 +118956,7 @@ var ts; case 81 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 270 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 273 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? @@ -116179,7 +118975,7 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 294 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 297 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); @@ -116230,11 +119026,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 328 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 333 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -116287,7 +119083,7 @@ var ts; isRightOfDot = contextToken.kind === 24 /* DotToken */; isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && @@ -116300,14 +119096,14 @@ var ts; return undefined; } break; - case 156 /* QualifiedName */: + case 157 /* QualifiedName */: node = parent.left; break; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: node = parent.name; break; - case 192 /* ImportType */: - case 223 /* MetaProperty */: + case 195 /* ImportType */: + case 226 /* MetaProperty */: node = parent; break; default: @@ -116320,7 +119116,7 @@ var ts; // <UI.Test /* completion position */ /> // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 198 /* PropertyAccessExpression */) { + if (parent && parent.kind === 201 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -116328,39 +119124,51 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 270 /* JsxElement */ || currentToken.parent.kind === 272 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 273 /* JsxElement */ || currentToken.parent.kind === 275 /* JsxOpeningElement */) { location = currentToken; } break; case 43 /* SlashToken */: - if (currentToken.parent.kind === 271 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 274 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 273 /* JsxClosingElement */: + case 276 /* JsxClosingElement */: if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 271 /* JsxSelfClosingElement */: - case 270 /* JsxElement */: - case 272 /* JsxOpeningElement */: + case 274 /* JsxSelfClosingElement */: + case 273 /* JsxElement */: + case 275 /* JsxOpeningElement */: isJsxIdentifierExpected = true; if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 277 /* JsxAttribute */: + case 283 /* JsxExpression */: + // For `<div foo={true} [||] ></div>`, `parent` will be `{true}` and `previousToken` will be `}` + if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { + isJsxIdentifierExpected = true; + } + break; + case 280 /* JsxAttribute */: + // For `<div className="x" [||] ></div>`, `parent` will be JsxAttribute and `previousToken` will be its initializer + if (parent.initializer === previousToken && + previousToken.end < position) { + isJsxIdentifierExpected = true; + break; + } switch (previousToken.kind) { case 62 /* EqualsToken */: isJsxInitializer = true; @@ -116442,11 +119250,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 322 /* JSDocParameterTag */: - case 328 /* JSDocPropertyTag */: - case 323 /* JSDocReturnTag */: - case 325 /* JSDocTypeTag */: - case 327 /* JSDocTypedefTag */: + case 326 /* JSDocParameterTag */: + case 333 /* JSDocPropertyTag */: + case 327 /* JSDocReturnTag */: + case 329 /* JSDocTypeTag */: + case 331 /* JSDocTypedefTag */: return true; default: return false; @@ -116462,7 +119270,7 @@ var ts; || ts.isPartOfTypeNode(node.parent) || ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker); var isRhsOfImportDeclaration = ts.isInRightSideOfInternalImportEqualsDeclaration(node); - if (ts.isEntityName(node) || isImportType) { + if (ts.isEntityName(node) || isImportType || ts.isPropertyAccessExpression(node)) { var isNamespaceName = ts.isModuleDeclaration(node.parent); if (isNamespaceName) isNewIdentifierLocation = true; @@ -116491,7 +119299,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 294 /* SourceFile */ && d.kind !== 253 /* ModuleDeclaration */ && d.kind !== 252 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 297 /* SourceFile */ && d.kind !== 256 /* ModuleDeclaration */ && d.kind !== 255 /* EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -116538,7 +119346,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 192 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 195 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -116551,7 +119359,7 @@ var ts; for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { - addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); + addPropertySymbol(symbol, /* insertAwait */ false, insertQuestionDot); } } } @@ -116587,13 +119395,20 @@ var ts; } else if (preferences.includeCompletionsWithInsertText) { addSymbolOriginInfo(symbol); + addSymbolSortInfo(symbol); symbols.push(symbol); } } else { addSymbolOriginInfo(symbol); + addSymbolSortInfo(symbol); symbols.push(symbol); } + function addSymbolSortInfo(symbol) { + if (isStaticProperty(symbol)) { + symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.LocalDeclarationPriority; + } + } function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { @@ -116695,7 +119510,7 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 294 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 297 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { @@ -116745,10 +119560,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 294 /* SourceFile */: - case 215 /* TemplateExpression */: - case 280 /* JsxExpression */: - case 227 /* Block */: + case 297 /* SourceFile */: + case 218 /* TemplateExpression */: + case 283 /* JsxExpression */: + case 230 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -116791,27 +119606,27 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && contextToken.kind === 111 /* TypeOfKeyword */ && - (contextToken.parent.kind === 175 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + (contextToken.parent.kind === 176 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 58 /* ColonToken */: - return parentKind === 162 /* PropertyDeclaration */ || - parentKind === 161 /* PropertySignature */ || - parentKind === 159 /* Parameter */ || - parentKind === 246 /* VariableDeclaration */ || + return parentKind === 163 /* PropertyDeclaration */ || + parentKind === 162 /* PropertySignature */ || + parentKind === 160 /* Parameter */ || + parentKind === 249 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 62 /* EqualsToken */: - return parentKind === 251 /* TypeAliasDeclaration */; + return parentKind === 254 /* TypeAliasDeclaration */; case 126 /* AsKeyword */: - return parentKind === 221 /* AsExpression */; + return parentKind === 224 /* AsExpression */; case 29 /* LessThanToken */: - return parentKind === 172 /* TypeReference */ || - parentKind === 203 /* TypeAssertionExpression */; + return parentKind === 173 /* TypeReference */ || + parentKind === 206 /* TypeAssertionExpression */; case 93 /* ExtendsKeyword */: - return parentKind === 158 /* TypeParameter */; + return parentKind === 159 /* TypeParameter */; } } return false; @@ -117022,7 +119837,7 @@ var ts; return true; } if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 272 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 275 /* JsxOpeningElement */) { // Two possibilities: // 1. <div>/**/ // - contextToken: GreaterThanToken (before cursor) @@ -117032,10 +119847,10 @@ var ts; // - contextToken: GreaterThanToken (before cursor) // - location: GreaterThanToken (after cursor) // - same parent (JSXOpeningElement) - return location.parent.kind !== 272 /* JsxOpeningElement */; + return location.parent.kind !== 275 /* JsxOpeningElement */; } - if (contextToken.parent.kind === 273 /* JsxClosingElement */ || contextToken.parent.kind === 271 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 270 /* JsxElement */; + if (contextToken.parent.kind === 276 /* JsxClosingElement */ || contextToken.parent.kind === 274 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 273 /* JsxElement */; } } return false; @@ -117046,40 +119861,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 200 /* CallExpression */ // func( a, | - || containingNodeKind === 165 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 201 /* NewExpression */ // new C(a, | - || containingNodeKind === 196 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 213 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 173 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 203 /* CallExpression */ // func( a, | + || containingNodeKind === 166 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 204 /* NewExpression */ // new C(a, | + || containingNodeKind === 199 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 216 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 174 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 200 /* CallExpression */ // func( | - || containingNodeKind === 165 /* Constructor */ // constructor( | - || containingNodeKind === 201 /* NewExpression */ // new C(a| - || containingNodeKind === 204 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 185 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 203 /* CallExpression */ // func( | + || containingNodeKind === 166 /* Constructor */ // constructor( | + || containingNodeKind === 204 /* NewExpression */ // new C(a| + || containingNodeKind === 207 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 186 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 196 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 170 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 157 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 138 /* ModuleKeyword */: // module | - case 139 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 199 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 171 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 158 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 139 /* ModuleKeyword */: // module | + case 140 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 253 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 256 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 249 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 252 /* ClassDeclaration */; // class A{ | case 62 /* EqualsToken */: - return containingNodeKind === 246 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 213 /* BinaryExpression */; // x = a| + return containingNodeKind === 249 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 216 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 215 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 218 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 225 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 228 /* TemplateSpan */; // `aa ${10} dd ${| case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: - return containingNodeKind === 162 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 163 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -117106,17 +119921,18 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 197 /* ObjectLiteralExpression */) { - var instantiatedType = typeChecker.getContextualType(objectLikeContainer); - var completionsType = instantiatedType && typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); - if (!instantiatedType || !completionsType) + if (objectLikeContainer.kind === 200 /* ObjectLiteralExpression */) { + var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); + if (instantiatedType === undefined) { return 2 /* Fail */; - isNewIdentifierLocation = ts.hasIndexSignature(instantiatedType || completionsType); + } + var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); + isNewIdentifierLocation = ts.hasIndexSignature(completionsType || instantiatedType); typeMembers = getPropertiesForObjectExpression(instantiatedType, completionsType, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 193 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 196 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -117127,12 +119943,12 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 236 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 159 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 239 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 160 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 164 /* MethodDeclaration */ || rootDeclaration.parent.kind === 167 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 165 /* MethodDeclaration */ || rootDeclaration.parent.kind === 168 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -117179,9 +119995,9 @@ var ts; if (!namedImportsOrExports) return 0 /* Continue */; // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 261 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 264 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) - return namedImportsOrExports.kind === 261 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 264 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -117334,11 +120150,11 @@ var ts; case 30 /* LessThanSlashToken */: case 43 /* SlashToken */: case 78 /* Identifier */: - case 198 /* PropertyAccessExpression */: - case 278 /* JsxAttributes */: - case 277 /* JsxAttribute */: - case 279 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 271 /* JsxSelfClosingElement */ || parent.kind === 272 /* JsxOpeningElement */)) { + case 201 /* PropertyAccessExpression */: + case 281 /* JsxAttributes */: + case 280 /* JsxAttribute */: + case 282 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 274 /* JsxSelfClosingElement */ || parent.kind === 275 /* JsxOpeningElement */)) { if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) @@ -117346,7 +120162,7 @@ var ts; } return parent; } - else if (parent.kind === 277 /* JsxAttribute */) { + else if (parent.kind === 280 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -117358,7 +120174,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 277 /* JsxAttribute */) || (parent.kind === 279 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 280 /* JsxAttribute */) || (parent.kind === 282 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -117368,8 +120184,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 280 /* JsxExpression */ && - parent.parent && parent.parent.kind === 277 /* JsxAttribute */) { + parent.kind === 283 /* JsxExpression */ && + parent.parent && parent.parent.kind === 280 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -117377,7 +120193,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 279 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 282 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -117397,51 +120213,51 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 246 /* VariableDeclaration */ || + return containingNodeKind === 249 /* VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 229 /* VariableStatement */ || - containingNodeKind === 252 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 232 /* VariableStatement */ || + containingNodeKind === 255 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 250 /* InterfaceDeclaration */ || // interface A<T, | - containingNodeKind === 194 /* ArrayBindingPattern */ || // var [x, y| - containingNodeKind === 251 /* TypeAliasDeclaration */ || // type Map, K, | + containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A<T, | + containingNodeKind === 197 /* ArrayBindingPattern */ || // var [x, y| + containingNodeKind === 254 /* TypeAliasDeclaration */ || // type Map, K, | // class A<T, | // var C = class D<T, | (ts.isClassLike(parent) && !!parent.typeParameters && parent.typeParameters.end >= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 194 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 197 /* ArrayBindingPattern */; // var [.| case 58 /* ColonToken */: - return containingNodeKind === 195 /* BindingElement */; // var {x :html| + return containingNodeKind === 198 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 194 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 197 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 284 /* CatchClause */ || + return containingNodeKind === 287 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 252 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 255 /* EnumDeclaration */; // enum a { | case 29 /* LessThanToken */: - return containingNodeKind === 249 /* ClassDeclaration */ || // class A< | - containingNodeKind === 218 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 250 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 251 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 252 /* ClassDeclaration */ || // class A< | + containingNodeKind === 221 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 254 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 123 /* StaticKeyword */: - return containingNodeKind === 162 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + return containingNodeKind === 163 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 159 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 194 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 160 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 197 /* ArrayBindingPattern */); // var [...z| case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: - return containingNodeKind === 159 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + return containingNodeKind === 160 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 126 /* AsKeyword */: - return containingNodeKind === 262 /* ImportSpecifier */ || - containingNodeKind === 267 /* ExportSpecifier */ || - containingNodeKind === 260 /* NamespaceImport */; + return containingNodeKind === 265 /* ImportSpecifier */ || + containingNodeKind === 270 /* ExportSpecifier */ || + containingNodeKind === 263 /* NamespaceImport */; case 134 /* GetKeyword */: - case 145 /* SetKeyword */: + case 146 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); case 83 /* ClassKeyword */: case 91 /* EnumKeyword */: @@ -117451,7 +120267,7 @@ var ts; case 99 /* ImportKeyword */: case 118 /* LetKeyword */: case 84 /* ConstKeyword */: - case 148 /* TypeKeyword */: // type htm| + case 149 /* TypeKeyword */: // type htm| return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); @@ -117498,7 +120314,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 165 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 166 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -117508,7 +120324,7 @@ var ts; return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 247 /* VariableDeclarationList */ + return node.parent.kind === 250 /* VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -117526,13 +120342,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 285 /* PropertyAssignment */ && - m.kind !== 286 /* ShorthandPropertyAssignment */ && - m.kind !== 195 /* BindingElement */ && - m.kind !== 164 /* MethodDeclaration */ && - m.kind !== 166 /* GetAccessor */ && - m.kind !== 167 /* SetAccessor */ && - m.kind !== 287 /* SpreadAssignment */) { + if (m.kind !== 288 /* PropertyAssignment */ && + m.kind !== 289 /* ShorthandPropertyAssignment */ && + m.kind !== 198 /* BindingElement */ && + m.kind !== 165 /* MethodDeclaration */ && + m.kind !== 167 /* GetAccessor */ && + m.kind !== 168 /* SetAccessor */ && + m.kind !== 290 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -117605,10 +120421,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 162 /* PropertyDeclaration */ && - m.kind !== 164 /* MethodDeclaration */ && - m.kind !== 166 /* GetAccessor */ && - m.kind !== 167 /* SetAccessor */) { + if (m.kind !== 163 /* PropertyDeclaration */ && + m.kind !== 165 /* MethodDeclaration */ && + m.kind !== 167 /* GetAccessor */ && + m.kind !== 168 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -117650,7 +120466,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 277 /* JsxAttribute */) { + if (attr.kind === 280 /* JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -117700,7 +120516,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 80 /* FirstKeyword */; i <= 155 /* LastKeyword */; i++) { + for (var i = 80 /* FirstKeyword */; i <= 156 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -117727,11 +120543,10 @@ var ts; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) || kind === 133 /* DeclareKeyword */ - || kind === 138 /* ModuleKeyword */ - || kind === 148 /* TypeKeyword */ - || kind === 139 /* NamespaceKeyword */ - || kind === 126 /* AsKeyword */ - || ts.isTypeKeyword(kind) && kind !== 149 /* UndefinedKeyword */; + || kind === 139 /* ModuleKeyword */ + || kind === 149 /* TypeKeyword */ + || kind === 140 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 150 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -117753,44 +120568,44 @@ var ts; switch (kind) { case 125 /* AbstractKeyword */: case 128 /* AnyKeyword */: - case 154 /* BigIntKeyword */: + case 155 /* BigIntKeyword */: case 131 /* BooleanKeyword */: case 133 /* DeclareKeyword */: case 91 /* EnumKeyword */: - case 153 /* GlobalKeyword */: + case 154 /* GlobalKeyword */: case 116 /* ImplementsKeyword */: case 135 /* InferKeyword */: case 117 /* InterfaceKeyword */: - case 136 /* IsKeyword */: - case 137 /* KeyOfKeyword */: - case 138 /* ModuleKeyword */: - case 139 /* NamespaceKeyword */: - case 140 /* NeverKeyword */: - case 143 /* NumberKeyword */: - case 144 /* ObjectKeyword */: + case 137 /* IsKeyword */: + case 138 /* KeyOfKeyword */: + case 139 /* ModuleKeyword */: + case 140 /* NamespaceKeyword */: + case 141 /* NeverKeyword */: + case 144 /* NumberKeyword */: + case 145 /* ObjectKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 122 /* PublicKeyword */: - case 141 /* ReadonlyKeyword */: - case 146 /* StringKeyword */: - case 147 /* SymbolKeyword */: - case 148 /* TypeKeyword */: - case 150 /* UniqueKeyword */: - case 151 /* UnknownKeyword */: + case 142 /* ReadonlyKeyword */: + case 147 /* StringKeyword */: + case 148 /* SymbolKeyword */: + case 149 /* TypeKeyword */: + case 151 /* UniqueKeyword */: + case 152 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 141 /* ReadonlyKeyword */; + return kind === 142 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { case 125 /* AbstractKeyword */: case 132 /* ConstructorKeyword */: case 134 /* GetKeyword */: - case 145 /* SetKeyword */: + case 146 /* SetKeyword */: case 129 /* AsyncKeyword */: case 133 /* DeclareKeyword */: return true; @@ -117801,6 +120616,7 @@ var ts; function isFunctionLikeBodyKeyword(kind) { return kind === 129 /* AsyncKeyword */ || kind === 130 /* AwaitKeyword */ + || kind === 126 /* AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -117851,7 +120667,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 329 /* SyntaxList */: + case 334 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -117954,6 +120770,19 @@ var ts; } return false; } + function isStaticProperty(symbol) { + return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); + } + function tryGetObjectLiteralContextualType(node, typeChecker) { + var type = typeChecker.getContextualType(node); + if (type) { + return type; + } + if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { + return typeChecker.getTypeAtLocation(node.parent); + } + return undefined; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -118037,8 +120866,8 @@ var ts; case 132 /* ConstructorKeyword */: return getFromAllDeclarations(ts.isConstructorDeclaration, [132 /* ConstructorKeyword */]); case 134 /* GetKeyword */: - case 145 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [134 /* GetKeyword */, 145 /* SetKeyword */]); + case 146 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [134 /* GetKeyword */, 146 /* SetKeyword */]); case 130 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); case 129 /* AsyncKeyword */: @@ -118086,7 +120915,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 294 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 297 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -118118,16 +120947,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 241 /* SwitchStatement */: - if (statement.kind === 237 /* ContinueStatement */) { + case 244 /* SwitchStatement */: + if (statement.kind === 240 /* ContinueStatement */) { return false; } // falls through - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 233 /* WhileStatement */: - case 232 /* DoStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 236 /* WhileStatement */: + case 235 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -118143,11 +120972,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 254 /* ModuleBlock */: - case 294 /* SourceFile */: - case 227 /* Block */: - case 281 /* CaseClause */: - case 282 /* DefaultClause */: + case 257 /* ModuleBlock */: + case 297 /* SourceFile */: + case 230 /* Block */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArrays(declaration.members, [declaration]); @@ -118155,14 +120984,14 @@ var ts; else { return container.statements; } - case 165 /* Constructor */: - case 164 /* MethodDeclaration */: - case 248 /* FunctionDeclaration */: + case 166 /* Constructor */: + case 165 /* MethodDeclaration */: + case 251 /* FunctionDeclaration */: return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 176 /* TypeLiteral */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 177 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. @@ -118176,6 +121005,9 @@ var ts; return __spreadArrays(nodes, [container]); } return nodes; + // Syntactically invalid positions that the parser might produce anyway + case 200 /* ObjectLiteralExpression */: + return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); } @@ -118195,7 +121027,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 96 /* ForKeyword */, 114 /* WhileKeyword */, 89 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 232 /* DoStatement */) { + if (loopNode.kind === 235 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 114 /* WhileKeyword */)) { @@ -118215,13 +121047,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 232 /* DoStatement */: - case 233 /* WhileStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -118588,41 +121420,39 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 200 /* CallExpression */: + case 203 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 246 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 249 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 78 /* Identifier */) { directImports.push(name); break; } } - // Don't support re-exporting 'require()' calls, so just add a single indirect user. - addIndirectUser(direct.getSourceFile()); } break; case 78 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 260 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 263 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 266 /* NamespaceExport */) { + else if (direct.exportClause.kind === 269 /* NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUsers(getSourceFileLikeForImportDeclaration(direct)); } @@ -118631,7 +121461,7 @@ var ts; directImports.push(direct); } break; - case 192 /* ImportType */: + case 195 /* ImportType */: directImports.push(direct); break; default: @@ -118648,7 +121478,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 294 /* SourceFile */ || sourceFileLike.kind === 253 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 297 /* SourceFile */ || sourceFileLike.kind === 256 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -118705,7 +121535,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 257 /* ImportEqualsDeclaration */) { + if (decl.kind === 260 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -118715,7 +121545,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 192 /* ImportType */) { + if (decl.kind === 195 /* ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { @@ -118731,7 +121561,7 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 264 /* ExportDeclaration */) { + if (decl.kind === 267 /* ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -118740,10 +121570,10 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 261 /* NamedImports */: + case 264 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -118793,7 +121623,7 @@ var ts; } } else { - var localSymbol = element.kind === 267 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 270 /* ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -118822,7 +121652,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 294 /* SourceFile */) { + if (searchSourceFile.kind === 297 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -118870,7 +121700,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 294 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 297 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -118885,15 +121715,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 264 /* ExportDeclaration */: - case 258 /* ImportDeclaration */: { + case 267 /* ExportDeclaration */: + case 261 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 257 /* ImportEqualsDeclaration */: { + case 260 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -118917,7 +121747,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 198 /* PropertyAccessExpression */) { + if (parent.kind === 201 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -119050,15 +121880,17 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 259 /* ImportClause */: - case 260 /* NamespaceImport */: + case 262 /* ImportClause */: + case 263 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; + case 198 /* BindingElement */: + return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent, /*requireStringLiteralLikeArgument*/ true); default: return false; } @@ -119081,6 +121913,14 @@ var ts; if (ts.isExportSpecifier(declaration) && !declaration.propertyName && !declaration.parent.parent.moduleSpecifier) { return checker.getExportSpecifierLocalTargetSymbol(declaration); } + else if (ts.isPropertyAccessExpression(declaration) && ts.isModuleExportsAccessExpression(declaration.expression) && !ts.isPrivateIdentifier(declaration.name)) { + return checker.getExportSpecifierLocalTargetSymbol(declaration.name); + } + else if (ts.isShorthandPropertyAssignment(declaration) + && ts.isBinaryExpression(declaration.parent.parent) + && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) { + return checker.getExportSpecifierLocalTargetSymbol(declaration.name); + } } } return symbol; @@ -119089,21 +121929,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 200 /* CallExpression */) { + if (node.kind === 203 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 294 /* SourceFile */) { + if (parent.kind === 297 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 254 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 257 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 253 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 256 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 269 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 272 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -119205,7 +122045,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -119213,28 +122053,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 195 /* BindingElement */: + case 198 /* BindingElement */: return getContextNode(node.parent.parent); - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: return node.parent.parent.parent; - case 267 /* ExportSpecifier */: - case 260 /* NamespaceImport */: + case 270 /* ExportSpecifier */: + case 263 /* NamespaceImport */: return node.parent.parent; - case 259 /* ImportClause */: - case 266 /* NamespaceExport */: + case 262 /* ImportClause */: + case 269 /* NamespaceExport */: return node.parent; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 236 /* ForOfStatement */: - case 235 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 238 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 285 /* PropertyAssignment */: - case 286 /* ShorthandPropertyAssignment */: + case 288 /* PropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -119291,9 +122131,9 @@ var ts; var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 198 /* PropertyAccessExpression */ - || node.parent.kind === 195 /* BindingElement */ - || node.parent.kind === 199 /* ElementAccessExpression */ + if (node.parent.kind === 201 /* PropertyAccessExpression */ + || node.parent.kind === 198 /* BindingElement */ + || node.parent.kind === 202 /* ElementAccessExpression */ || node.kind === 105 /* SuperKeyword */) { referenceEntries = entries && __spreadArrays(entries); } @@ -119317,13 +122157,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 294 /* SourceFile */) { + if (node.kind === 297 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 286 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 289 /* ShorthandPropertyAssignment */) { var result_1 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; @@ -119489,13 +122329,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 197 /* ObjectLiteralExpression */) { + else if (node.kind === 200 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 218 /* ClassExpression */) { + else if (node.kind === 221 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -119556,47 +122396,47 @@ var ts; if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 213 /* BinaryExpression */: - case 195 /* BindingElement */: - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 216 /* BinaryExpression */: + case 198 /* BindingElement */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: case 87 /* DefaultKeyword */: - case 252 /* EnumDeclaration */: - case 288 /* EnumMember */: - case 267 /* ExportSpecifier */: - case 259 /* ImportClause */: // default import - case 257 /* ImportEqualsDeclaration */: - case 262 /* ImportSpecifier */: - case 250 /* InterfaceDeclaration */: - case 320 /* JSDocCallbackTag */: - case 327 /* JSDocTypedefTag */: - case 277 /* JsxAttribute */: - case 253 /* ModuleDeclaration */: - case 256 /* NamespaceExportDeclaration */: - case 260 /* NamespaceImport */: - case 266 /* NamespaceExport */: - case 159 /* Parameter */: - case 286 /* ShorthandPropertyAssignment */: - case 251 /* TypeAliasDeclaration */: - case 158 /* TypeParameter */: + case 255 /* EnumDeclaration */: + case 291 /* EnumMember */: + case 270 /* ExportSpecifier */: + case 262 /* ImportClause */: // default import + case 260 /* ImportEqualsDeclaration */: + case 265 /* ImportSpecifier */: + case 253 /* InterfaceDeclaration */: + case 324 /* JSDocCallbackTag */: + case 331 /* JSDocTypedefTag */: + case 280 /* JsxAttribute */: + case 256 /* ModuleDeclaration */: + case 259 /* NamespaceExportDeclaration */: + case 263 /* NamespaceImport */: + case 269 /* NamespaceExport */: + case 160 /* Parameter */: + case 289 /* ShorthandPropertyAssignment */: + case 254 /* TypeAliasDeclaration */: + case 159 /* TypeParameter */: return true; - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 165 /* Constructor */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 166 /* Constructor */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return !!decl.body; - case 246 /* VariableDeclaration */: - case 162 /* PropertyDeclaration */: + case 249 /* VariableDeclaration */: + case 163 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 163 /* MethodSignature */: - case 161 /* PropertySignature */: - case 328 /* JSDocPropertyTag */: - case 322 /* JSDocParameterTag */: + case 164 /* MethodSignature */: + case 162 /* PropertySignature */: + case 333 /* JSDocPropertyTag */: + case 326 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -119757,10 +122597,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 294 /* SourceFile */: + case 297 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } @@ -119789,9 +122629,9 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 141 /* ReadonlyKeyword */ + return node.kind === 142 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 141 /* ReadonlyKeyword */; + && node.parent.operator === 142 /* ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { @@ -119802,12 +122642,12 @@ var ts; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 141 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 142 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 141 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 142 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -120108,7 +122948,7 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 205 /* FunctionExpression */ || valueDeclaration.kind === 218 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 208 /* FunctionExpression */ || valueDeclaration.kind === 221 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -120118,7 +122958,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierPropertyDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 249 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 252 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -120147,7 +122987,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 294 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -120519,14 +123359,14 @@ var ts; for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 132 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 165 /* Constructor */ && !!ctrKeyword); + ts.Debug.assert(decl.kind === 166 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 164 /* MethodDeclaration */) { + if (decl && decl.kind === 165 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 107 /* ThisKeyword */, function (thisKeyword) { @@ -120550,7 +123390,7 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 165 /* Constructor */); + ts.Debug.assert(decl.kind === 166 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 105 /* SuperKeyword */, function (node) { @@ -120580,7 +123420,7 @@ var ts; if (refNode.kind !== 78 /* Identifier */) { return; } - if (refNode.parent.kind === 286 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 289 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -120600,7 +123440,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 227 /* Block */) { + if (body.kind === 230 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -120628,13 +123468,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 204 /* ParenthesizedExpression */: + case 207 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 206 /* ArrowFunction */: - case 205 /* FunctionExpression */: - case 197 /* ObjectLiteralExpression */: - case 218 /* ClassExpression */: - case 196 /* ArrayLiteralExpression */: + case 209 /* ArrowFunction */: + case 208 /* FunctionExpression */: + case 200 /* ObjectLiteralExpression */: + case 221 /* ClassExpression */: + case 199 /* ArrayLiteralExpression */: return true; default: return false; @@ -120687,13 +123527,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -120714,41 +123554,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 78 /* Identifier */ && node.parent.kind === 159 /* Parameter */ && node.parent.name === node; + return node.kind === 78 /* Identifier */ && node.parent.kind === 160 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 294 /* SourceFile */: + case 297 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 294 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 297 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -120756,19 +123596,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 205 /* FunctionExpression */: - case 248 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 218 /* ClassExpression */: - case 249 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 252 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getSyntacticModifierFlags(container) & 32 /* Static */) === staticFlag; - case 294 /* SourceFile */: - return container.kind === 294 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 297 /* SourceFile */: + return container.kind === 297 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); @@ -120867,7 +123707,7 @@ var ts; ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 267 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 270 /* ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { @@ -120912,7 +123752,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 195 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 198 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -121139,16 +123979,16 @@ var ts; return; } switch (node.kind) { - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 164 /* MethodDeclaration */: - if (node.parent.kind === 197 /* ObjectLiteralExpression */) { + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 165 /* MethodDeclaration */: + if (node.parent.kind === 200 /* ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 248 /* FunctionDeclaration */: - case 249 /* ClassDeclaration */: - case 253 /* ModuleDeclaration */: + case 251 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 256 /* ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -121354,55 +124194,55 @@ var ts; } switch (node.kind) { case 78 /* Identifier */: - case 257 /* ImportEqualsDeclaration */: - case 258 /* ImportDeclaration */: - case 264 /* ExportDeclaration */: - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: + case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportDeclaration */: + case 267 /* ExportDeclaration */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 203 /* TypeAssertionExpression */: - case 221 /* AsExpression */: + case 206 /* TypeAssertionExpression */: + case 224 /* AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 246 /* VariableDeclaration */: - case 159 /* Parameter */: + case 249 /* VariableDeclaration */: + case 160 /* Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 200 /* CallExpression */: + case 203 /* CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 201 /* NewExpression */: + case 204 /* NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 202 /* TaggedTemplateExpression */: + case 205 /* TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 272 /* JsxOpeningElement */: - case 271 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: + case 274 /* JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 160 /* Decorator */: + case 161 /* Decorator */: recordCallSite(node); collect(node.expression); return; - case 198 /* PropertyAccessExpression */: - case 199 /* ElementAccessExpression */: + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -121452,22 +124292,22 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 294 /* SourceFile */: + case 297 /* SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; default: @@ -121748,9 +124588,7 @@ var ts; var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. - if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); }) || - // TODO: GH#25533 Following check shouldn't be necessary if 'require' is an alias - symbol.declarations && symbol.declarations.some(function (d) { return ts.isVariableDeclaration(d) && !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false); })) { + if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) { return [sigInfo]; } else { @@ -121764,7 +124602,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 286 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 289 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -121809,6 +124647,11 @@ var ts; return getDefinitionFromSymbol(typeChecker, symbol, node); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; + function isShorthandPropertyAssignmentOfModuleExports(symbol) { + var shorthandProperty = ts.tryCast(symbol.valueDeclaration, ts.isShorthandPropertyAssignment); + var binaryExpression = ts.tryCast(shorthandProperty === null || shorthandProperty === void 0 ? void 0 : shorthandProperty.parent.parent, ts.isAssignmentExpression); + return !!binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) === 2 /* ModuleExports */; + } /** * True if we should not add definitions for both the signature symbol and the definition symbol. * True for `const |f = |() => 0`, false for `function |f() {} const |g = f;`. @@ -121906,19 +124749,24 @@ var ts; // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if (symbol && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { - var aliased = checker.getAliasedSymbol(symbol); - if (aliased.declarations) { - return aliased; + while (symbol) { + if (symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + var aliased = checker.getAliasedSymbol(symbol); + if (!aliased.declarations) { + break; + } + symbol = aliased; } - } - if (symbol && ts.isInJSFile(node)) { - var requireCall = ts.forEach(symbol.declarations, function (d) { return ts.isVariableDeclaration(d) && !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true) ? d.initializer : undefined; }); - if (requireCall) { - var moduleSymbol = checker.getSymbolAtLocation(requireCall.arguments[0]); - if (moduleSymbol) { - return checker.resolveExternalModuleSymbol(moduleSymbol); + else if (isShorthandPropertyAssignmentOfModuleExports(symbol)) { + // Skip past `module.exports = { Foo }` even though 'Foo' is not a real alias + var shorthandTarget = checker.resolveName(symbol.name, symbol.valueDeclaration, 111551 /* Value */, /*excludeGlobals*/ false); + if (!ts.some(shorthandTarget === null || shorthandTarget === void 0 ? void 0 : shorthandTarget.declarations)) { + break; } + symbol = shorthandTarget; + } + else { + break; } } return symbol; @@ -121936,11 +124784,14 @@ var ts; return true; } switch (declaration.kind) { - case 259 /* ImportClause */: - case 257 /* ImportEqualsDeclaration */: + case 262 /* ImportClause */: + case 260 /* ImportEqualsDeclaration */: return true; - case 262 /* ImportSpecifier */: - return declaration.parent.kind === 261 /* NamedImports */; + case 265 /* ImportSpecifier */: + return declaration.parent.kind === 264 /* NamedImports */; + case 198 /* BindingElement */: + case 249 /* VariableDeclaration */: + return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration, /*requireStringLiteralLikeArgument*/ true); default: return false; } @@ -122025,9 +124876,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 165 /* Constructor */: - case 174 /* ConstructorType */: - case 169 /* ConstructSignature */: + case 166 /* Constructor */: + case 175 /* ConstructorType */: + case 170 /* ConstructSignature */: return true; default: return false; @@ -122142,11 +124993,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 322 /* JSDocParameterTag */: - case 328 /* JSDocPropertyTag */: + case 326 /* JSDocParameterTag */: + case 333 /* JSDocPropertyTag */: return [declaration]; - case 320 /* JSDocCallbackTag */: - case 327 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: + case 331 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -122167,18 +125018,19 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 312 /* JSDocImplementsTag */: + case 316 /* JSDocImplementsTag */: return withNode(tag.class); - case 311 /* JSDocAugmentsTag */: + case 315 /* JSDocAugmentsTag */: return withNode(tag.class); - case 326 /* JSDocTemplateTag */: + case 330 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 325 /* JSDocTypeTag */: + case 329 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 327 /* JSDocTypedefTag */: - case 320 /* JSDocCallbackTag */: - case 328 /* JSDocPropertyTag */: - case 322 /* JSDocParameterTag */: + case 331 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: + case 333 /* JSDocPropertyTag */: + case 326 /* JSDocParameterTag */: + case 332 /* JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -122200,7 +125052,7 @@ var ts; name: tagName, kind: "keyword" /* keyword */, kindModifiers: "", - sortText: "0", + sortText: ts.Completions.SortText.LocationPriority, }; })); } @@ -122212,7 +125064,7 @@ var ts; name: "@" + tagName, kind: "keyword" /* keyword */, kindModifiers: "", - sortText: "0" + sortText: ts.Completions.SortText.LocationPriority }; })); } @@ -122246,7 +125098,7 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: "0" }; + return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; @@ -122347,23 +125199,24 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 164 /* MethodDeclaration */: - case 165 /* Constructor */: - case 163 /* MethodSignature */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 165 /* MethodDeclaration */: + case 166 /* Constructor */: + case 164 /* MethodSignature */: + case 209 /* ArrowFunction */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 161 /* PropertySignature */: - case 252 /* EnumDeclaration */: - case 288 /* EnumMember */: - case 251 /* TypeAliasDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 162 /* PropertySignature */: + case 255 /* EnumDeclaration */: + case 291 /* EnumMember */: + case 254 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 229 /* VariableStatement */: { + case 232 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -122371,16 +125224,16 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 294 /* SourceFile */: + case 297 /* SourceFile */: return "quit"; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 253 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 230 /* ExpressionStatement */: + return commentOwner.parent.kind === 256 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 233 /* ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression); - case 213 /* BinaryExpression */: { + case 216 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -122388,7 +125241,7 @@ var ts; var parameters_2 = ts.isFunctionLike(be.right) ? be.right.parameters : ts.emptyArray; return { commentOwner: commentOwner, parameters: parameters_2 }; } - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters }; @@ -122404,14 +125257,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 204 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 207 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return rightHandSide.parameters; - case 218 /* ClassExpression */: { + case 221 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -122473,9 +125326,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 259 /* ImportClause */: - case 262 /* ImportSpecifier */: - case 257 /* ImportEqualsDeclaration */: + case 262 /* ImportClause */: + case 265 /* ImportSpecifier */: + case 260 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -122485,7 +125338,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 157 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 158 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -122502,7 +125355,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 157 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 158 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -122710,7 +125563,7 @@ var ts; return; } switch (node.kind) { - case 165 /* Constructor */: + case 166 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -122722,21 +125575,21 @@ var ts; } } break; - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 163 /* MethodSignature */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 164 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 259 /* ImportClause */: + case 262 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -122748,7 +125601,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 260 /* NamespaceImport */) { + if (namedBindings.kind === 263 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -122759,17 +125612,17 @@ var ts; } } break; - case 286 /* ShorthandPropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 287 /* SpreadAssignment */: + case 290 /* SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as <unknown>. ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 195 /* BindingElement */: - case 285 /* PropertyAssignment */: - case 246 /* VariableDeclaration */: + case 198 /* BindingElement */: + case 288 /* PropertyAssignment */: + case 249 /* VariableDeclaration */: var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -122784,7 +125637,7 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -122792,11 +125645,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 206 /* ArrowFunction */: - case 205 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 208 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -122806,9 +125659,9 @@ var ts; } endNode(); break; - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: startNode(node); for (var _h = 0, _j = node.members; _h < _j.length; _h++) { var member = _j[_h]; @@ -122816,12 +125669,12 @@ var ts; } endNode(); break; - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 263 /* ExportAssignment */: { + case 266 /* ExportAssignment */: { var expression_1 = node.expression; - var child = ts.isObjectLiteralExpression(expression_1) ? expression_1 : + var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; if (child) { startNode(node); @@ -122833,16 +125686,16 @@ var ts; } break; } - case 267 /* ExportSpecifier */: - case 257 /* ImportEqualsDeclaration */: - case 170 /* IndexSignature */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 251 /* TypeAliasDeclaration */: + case 270 /* ExportSpecifier */: + case 260 /* ImportEqualsDeclaration */: + case 171 /* IndexSignature */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 254 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 200 /* CallExpression */: - case 213 /* BinaryExpression */: { + case 203 /* CallExpression */: + case 216 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -123084,12 +125937,12 @@ var ts; return false; } switch (a.kind) { - case 162 /* PropertyDeclaration */: - case 164 /* MethodDeclaration */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 163 /* PropertyDeclaration */: + case 165 /* MethodDeclaration */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: return ts.hasSyntacticModifier(a, 32 /* Static */) === ts.hasSyntacticModifier(b, 32 /* Static */); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -123105,7 +125958,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 253 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 256 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -123135,7 +125988,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 253 /* ModuleDeclaration */) { + if (node.kind === 256 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -123144,16 +125997,16 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 218 /* ClassExpression */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 221 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 253 /* ModuleDeclaration */) { + if (node.kind === 256 /* ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { @@ -123165,18 +126018,18 @@ var ts; } } switch (node.kind) { - case 294 /* SourceFile */: + case 297 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : "<global>"; - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 206 /* ArrowFunction */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: + case 209 /* ArrowFunction */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -123184,13 +126037,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 165 /* Constructor */: + case 166 /* Constructor */: return "constructor"; - case 169 /* ConstructSignature */: + case 170 /* ConstructSignature */: return "new()"; - case 168 /* CallSignature */: + case 169 /* CallSignature */: return "()"; - case 170 /* IndexSignature */: + case 171 /* IndexSignature */: return "[]"; default: return "<unknown>"; @@ -123223,19 +126076,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 252 /* EnumDeclaration */: - case 250 /* InterfaceDeclaration */: - case 253 /* ModuleDeclaration */: - case 294 /* SourceFile */: - case 251 /* TypeAliasDeclaration */: - case 327 /* JSDocTypedefTag */: - case 320 /* JSDocCallbackTag */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 255 /* EnumDeclaration */: + case 253 /* InterfaceDeclaration */: + case 256 /* ModuleDeclaration */: + case 297 /* SourceFile */: + case 254 /* TypeAliasDeclaration */: + case 331 /* JSDocTypedefTag */: + case 324 /* JSDocCallbackTag */: return true; - case 206 /* ArrowFunction */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -123245,10 +126098,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 254 /* ModuleBlock */: - case 294 /* SourceFile */: - case 164 /* MethodDeclaration */: - case 165 /* Constructor */: + case 257 /* ModuleBlock */: + case 297 /* SourceFile */: + case 165 /* MethodDeclaration */: + case 166 /* Constructor */: return true; default: return false; @@ -123306,9 +126159,8 @@ var ts; return ts.getTextOfNode(moduleDeclaration.name); } // Otherwise, we need to aggregate each identifier to build up the qualified name. - var result = []; - result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 253 /* ModuleDeclaration */) { + var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; + while (moduleDeclaration.body && moduleDeclaration.body.kind === 256 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -123322,13 +126174,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 157 /* ComputedPropertyName */; + return !member.name || member.name.kind === 158 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 294 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 297 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 246 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 249 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -123386,9 +126238,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 206 /* ArrowFunction */: - case 205 /* FunctionExpression */: - case 218 /* ClassExpression */: + case 209 /* ArrowFunction */: + case 208 /* FunctionExpression */: + case 221 /* ClassExpression */: return true; default: return false; @@ -123742,11 +126594,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return declaration.moduleSpecifier; - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -123785,19 +126637,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 260 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 263 /* NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return 5; - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return 6; } } @@ -123843,12 +126695,9 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || n.kind === 1 /* EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } - if (isFunctionExpressionAssignedToVariable(n)) { - addOutliningForLeadingCommentsForNode(n.parent.parent.parent, sourceFile, cancellationToken, out); - } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { addOutliningForLeadingCommentsForNode(n.parent.left, sourceFile, cancellationToken, out); } @@ -123876,13 +126725,6 @@ var ts; } depthRemaining++; } - function isFunctionExpressionAssignedToVariable(n) { - if (!ts.isFunctionExpression(n) && !ts.isArrowFunction(n)) { - return false; - } - var ancestor = ts.findAncestor(n, ts.isVariableStatement); - return !!ancestor && ts.getSingleInitializerOfVariableStatementOrPropertyDeclaration(ancestor) === n; - } } function addRegionOutliningSpans(sourceFile, out) { var regions = []; @@ -123963,7 +126805,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 227 /* Block */: + case 230 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -123971,16 +126813,16 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 232 /* DoStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 234 /* ForStatement */: - case 231 /* IfStatement */: - case 233 /* WhileStatement */: - case 240 /* WithStatement */: - case 284 /* CatchClause */: + case 235 /* DoStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 237 /* ForStatement */: + case 234 /* IfStatement */: + case 236 /* WhileStatement */: + case 243 /* WithStatement */: + case 287 /* CatchClause */: return spanForNode(n.parent); - case 244 /* TryStatement */: + case 247 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -123997,40 +126839,40 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 254 /* ModuleBlock */: + case 257 /* ModuleBlock */: return spanForNode(n.parent); - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: - case 255 /* CaseBlock */: - case 176 /* TypeLiteral */: - case 193 /* ObjectBindingPattern */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: + case 258 /* CaseBlock */: + case 177 /* TypeLiteral */: + case 196 /* ObjectBindingPattern */: return spanForNode(n); - case 178 /* TupleType */: + case 179 /* TupleType */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 281 /* CaseClause */: - case 282 /* DefaultClause */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: return spanForNodeArray(n.statements); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 270 /* JsxElement */: + case 273 /* JsxElement */: return spanForJSXElement(n); - case 274 /* JsxFragment */: + case 277 /* JsxFragment */: return spanForJSXFragment(n); - case 271 /* JsxSelfClosingElement */: - case 272 /* JsxOpeningElement */: + case 274 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 215 /* TemplateExpression */: + case 218 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 194 /* ArrayBindingPattern */: + case 197 /* ArrayBindingPattern */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return spanForArrowFunction(n); - case 200 /* CallExpression */: + case 203 /* CallExpression */: return spanForCallExpression(n); } function spanForCallExpression(node) { @@ -124097,7 +126939,7 @@ var ts; function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 206 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 209 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -124644,7 +127486,7 @@ var ts; if (token === 133 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 138 /* ModuleKeyword */) { + if (token === 139 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -124678,10 +127520,10 @@ var ts; return true; } else { - if (token === 148 /* TypeKeyword */) { + if (token === 149 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 152 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || + return token !== 153 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || token === 18 /* OpenBraceToken */ || token === 78 /* Identifier */ || ts.isKeyword(token)); @@ -124692,7 +127534,7 @@ var ts; } if (token === 78 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 152 /* FromKeyword */) { + if (token === 153 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -124723,7 +127565,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 152 /* FromKeyword */) { + if (token === 153 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -124739,7 +127581,7 @@ var ts; token = nextToken(); if (token === 78 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 152 /* FromKeyword */) { + if (token === 153 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -124760,7 +127602,7 @@ var ts; if (token === 92 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 148 /* TypeKeyword */) { + if (token === 149 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); return token === 41 /* AsteriskToken */ || @@ -124779,7 +127621,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 152 /* FromKeyword */) { + if (token === 153 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -124791,7 +127633,7 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 152 /* FromKeyword */) { + if (token === 153 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -124801,7 +127643,7 @@ var ts; } else if (token === 99 /* ImportKeyword */) { token = nextToken(); - if (token === 148 /* TypeKeyword */) { + if (token === 149 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); return token === 78 /* Identifier */ || @@ -124827,7 +127669,7 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 142 /* RequireKeyword */) { + if (token === 143 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -124970,8 +127812,13 @@ var ts; Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile, options) { var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) - return; + if (!symbol) { + if (ts.isLabelName(node)) { + var name = ts.getTextOfNode(node); + return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile); + } + return undefined; + } // Only allow a symbol to be renamed if it actually has at least one declaration. var declarations = symbol.declarations; if (!declarations || declarations.length === 0) @@ -124988,7 +127835,7 @@ var ts; return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 157 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 158 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -125064,6 +127911,7 @@ var ts; var SmartSelectionRange; (function (SmartSelectionRange) { function getSmartSelectionRange(pos, sourceFile) { + var _a; var selectionRange = { textSpan: ts.createTextSpanFromBounds(sourceFile.getFullStart(), sourceFile.getEnd()) }; @@ -125076,7 +127924,7 @@ var ts; var prevNode = children[i - 1]; var node = children[i]; var nextNode = children[i + 1]; - if (node.getStart(sourceFile) > pos) { + if (ts.getTokenPosOfNode(node, sourceFile, /*includeJsDoc*/ true) > pos) { break outer; } if (positionShouldSnapToNode(sourceFile, pos, node)) { @@ -125085,14 +127933,14 @@ var ts; // of things that should be considered independently. // 3. A VariableStatement’s children are just a VaraiableDeclarationList and a semicolon. // 4. A lone VariableDeclaration in a VaraibleDeclaration feels redundant with the VariableStatement. - // // Dive in without pushing a selection range. if (ts.isBlock(node) || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) - || ts.isVariableDeclaration(node) && ts.isSyntaxList(parentNode) && children.length === 1) { + || ts.isVariableDeclaration(node) && ts.isSyntaxList(parentNode) && children.length === 1 + || ts.isJSDocTypeExpression(node) || ts.isJSDocSignature(node) || ts.isJSDocTypeLiteral(node)) { parentNode = node; break; } @@ -125104,15 +127952,12 @@ var ts; } // Blocks with braces, brackets, parens, or JSX tags on separate lines should be // selected from open to close, including whitespace but not including the braces/etc. themselves. - var isBetweenMultiLineBookends = ts.isSyntaxList(node) - && isListOpener(prevNode) - && isListCloser(nextNode) + var isBetweenMultiLineBookends = ts.isSyntaxList(node) && isListOpener(prevNode) && isListCloser(nextNode) && !ts.positionsAreOnSameLine(prevNode.getStart(), nextNode.getStart(), sourceFile); - var jsDocCommentStart = ts.hasJSDocNodes(node) && node.jsDoc[0].getStart(); var start = isBetweenMultiLineBookends ? prevNode.getEnd() : node.getStart(); - var end = isBetweenMultiLineBookends ? nextNode.getStart() : node.getEnd(); - if (ts.isNumber(jsDocCommentStart)) { - pushSelectionRange(jsDocCommentStart, end); + var end = isBetweenMultiLineBookends ? nextNode.getStart() : getEndPos(sourceFile, node); + if (ts.hasJSDocNodes(node) && ((_a = node.jsDoc) === null || _a === void 0 ? void 0 : _a.length)) { + pushSelectionRange(ts.first(node.jsDoc).getStart(), end); } pushSelectionRange(start, end); // String literals should have a stop both inside and outside their quotes. @@ -125200,14 +128045,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 141 /* ReadonlyKeyword */ || + return child === node.readonlyToken || child.kind === 142 /* ReadonlyKeyword */ || child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 158 /* TypeParameter */ || + kind === 159 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -125321,14 +128166,26 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 272 /* JsxOpeningElement */; + || kind === 275 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 273 /* JsxClosingElement */; + || kind === 276 /* JsxClosingElement */; + } + function getEndPos(sourceFile, node) { + switch (node.kind) { + case 326 /* JSDocParameterTag */: + case 324 /* JSDocCallbackTag */: + case 333 /* JSDocPropertyTag */: + case 331 /* JSDocTypedefTag */: + case 328 /* JSDocThisTag */: + return sourceFile.getLineEndOfPosition(node.getStart()); + default: + return node.getEnd(); + } } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -125534,10 +128391,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 202 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 205 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 215 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 218 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -125606,17 +128463,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 204 /* ParenthesizedExpression */: - case 164 /* MethodDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 207 /* ParenthesizedExpression */: + case 165 /* MethodDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 213 /* BinaryExpression */: { + case 216 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -125740,7 +128597,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 215 /* TemplateExpression */) { + if (template.kind === 218 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -126092,7 +128949,7 @@ var ts; return diags.sort(function (d1, d2) { return d1.start - d2.start; }); function check(node) { if (isJsFile) { - if (canBeConvertedToClass(node)) { + if (canBeConvertedToClass(node, checker)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); } } @@ -126121,11 +128978,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 230 /* ExpressionStatement */: { + case 233 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -126142,12 +128999,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 260 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 263 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -126216,9 +129073,9 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through case 103 /* NullKeyword */: @@ -126231,17 +129088,16 @@ var ts; function getKeyFromNode(exp) { return exp.pos.toString() + ":" + exp.end.toString(); } - function canBeConvertedToClass(node) { + function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 205 /* FunctionExpression */) { + if (node.kind === 208 /* FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } - var decl = ts.getDeclarationOfExpando(node); - var symbol = decl === null || decl === void 0 ? void 0 : decl.symbol; + var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 248 /* FunctionDeclaration */) { + if (node.kind === 251 /* FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; @@ -126261,7 +129117,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 218 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -126347,11 +129203,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 272 /* JsxOpeningElement */: - case 270 /* JsxElement */: - case 271 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: + case 273 /* JsxElement */: + case 274 /* JsxSelfClosingElement */: return location.kind === 78 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 277 /* JsxAttribute */: + case 280 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -126395,7 +129251,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 198 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 201 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -126415,7 +129271,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 201 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 105 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 204 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 105 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -126471,7 +129327,7 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 132 /* ConstructorKeyword */ && location.parent.kind === 165 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 132 /* ConstructorKeyword */ && location.parent.kind === 166 /* Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration @@ -126479,21 +129335,21 @@ var ts; return declaration === (location.kind === 132 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 165 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 166 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 165 /* Constructor */) { + if (functionDeclaration_1.kind === 166 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 168 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 169 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -126504,7 +129360,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 218 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class <className> @@ -126527,7 +129383,7 @@ var ts; } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(148 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -126548,9 +129404,9 @@ var ts; } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 253 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 256 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 78 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 139 /* NamespaceKeyword */ : 138 /* ModuleKeyword */)); + displayParts.push(ts.keywordPart(isNamespace ? 140 /* NamespaceKeyword */ : 139 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -126569,7 +129425,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 158 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 159 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -126577,21 +129433,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 169 /* ConstructSignature */) { + if (declaration.kind === 170 /* ConstructSignature */) { displayParts.push(ts.keywordPart(102 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 168 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 169 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 251 /* TypeAliasDeclaration */) { + else if (declaration.kind === 254 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list<T> = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(148 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -126603,7 +129459,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 288 /* EnumMember */) { + if (declaration.kind === 291 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -126634,17 +129490,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 256 /* NamespaceExportDeclaration */: + case 259 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(139 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(140 /* NamespaceKeyword */)); break; - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 87 /* DefaultKeyword */)); break; - case 267 /* ExportSpecifier */: + case 270 /* ExportSpecifier */: displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); break; default: @@ -126653,13 +129509,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 257 /* ImportEqualsDeclaration */) { + if (declaration.kind === 260 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(142 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(143 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -126740,10 +129596,10 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 294 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 297 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 213 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 216 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -126861,16 +129717,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 205 /* FunctionExpression */) { + if (declaration.kind === 208 /* FunctionExpression */) { return true; } - if (declaration.kind !== 246 /* VariableDeclaration */ && declaration.kind !== 248 /* FunctionDeclaration */) { + if (declaration.kind !== 249 /* VariableDeclaration */ && declaration.kind !== 251 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 294 /* SourceFile */ || parent.kind === 254 /* ModuleBlock */) { + if (parent.kind === 297 /* SourceFile */ || parent.kind === 257 /* ModuleBlock */) { return false; } } @@ -127171,10 +130027,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 277 /* JsxAttribute */: - case 272 /* JsxOpeningElement */: - case 273 /* JsxClosingElement */: - case 271 /* JsxSelfClosingElement */: + case 280 /* JsxAttribute */: + case 275 /* JsxOpeningElement */: + case 276 /* JsxClosingElement */: + case 274 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. return ts.isKeyword(node.kind) || node.kind === 78 /* Identifier */; } @@ -127375,7 +130231,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 155 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 156 /* LastToken */; token++) { if (token !== 1 /* EndOfFileToken */) { allTokens.push(token); } @@ -127390,9 +130246,9 @@ var ts; var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); var anyTokenIncludingEOF = tokenRangeFrom(__spreadArrays(allTokens, [1 /* EndOfFileToken */])); - var keywords = tokenRangeFromRange(80 /* FirstKeyword */, 155 /* LastKeyword */); + var keywords = tokenRangeFromRange(80 /* FirstKeyword */, 156 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 77 /* LastBinaryOperator */); - var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 155 /* OfKeyword */, 126 /* AsKeyword */, 136 /* IsKeyword */]; + var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 156 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, @@ -127466,7 +130322,7 @@ var ts; // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [134 /* GetKeyword */, 145 /* SetKeyword */], 78 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterGetSetInMember", [134 /* GetKeyword */, 146 /* SetKeyword */], 78 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), rule("NoSpaceBetweenYieldKeywordAndStar", 124 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), rule("SpaceBetweenYieldOrYieldStarAndOperand", [124 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), rule("NoSpaceBetweenReturnAndSemicolon", 104 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), @@ -127490,7 +130346,7 @@ var ts; rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [138 /* ModuleKeyword */, 142 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [139 /* ModuleKeyword */, 143 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ 125 /* AbstractKeyword */, @@ -127504,20 +130360,20 @@ var ts; 116 /* ImplementsKeyword */, 99 /* ImportKeyword */, 117 /* InterfaceKeyword */, - 138 /* ModuleKeyword */, - 139 /* NamespaceKeyword */, + 139 /* ModuleKeyword */, + 140 /* NamespaceKeyword */, 120 /* PrivateKeyword */, 122 /* PublicKeyword */, 121 /* ProtectedKeyword */, - 141 /* ReadonlyKeyword */, - 145 /* SetKeyword */, + 142 /* ReadonlyKeyword */, + 146 /* SetKeyword */, 123 /* StaticKeyword */, - 148 /* TypeKeyword */, - 152 /* FromKeyword */, - 137 /* KeyOfKeyword */, + 149 /* TypeKeyword */, + 153 /* FromKeyword */, + 138 /* KeyOfKeyword */, 135 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [93 /* ExtendsKeyword */, 116 /* ImplementsKeyword */, 152 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [93 /* ExtendsKeyword */, 116 /* ImplementsKeyword */, 153 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions @@ -127549,7 +130405,7 @@ var ts; 120 /* PrivateKeyword */, 121 /* ProtectedKeyword */, 134 /* GetKeyword */, - 145 /* SetKeyword */, + 146 /* SetKeyword */, 22 /* OpenBracketToken */, 41 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), @@ -127703,51 +130559,51 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 234 /* ForStatement */; + return context.contextNode.kind === 237 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 214 /* ConditionalExpression */: - case 183 /* ConditionalType */: - case 221 /* AsExpression */: - case 267 /* ExportSpecifier */: - case 262 /* ImportSpecifier */: - case 171 /* TypePredicate */: - case 181 /* UnionType */: - case 182 /* IntersectionType */: + case 217 /* ConditionalExpression */: + case 184 /* ConditionalType */: + case 224 /* AsExpression */: + case 270 /* ExportSpecifier */: + case 265 /* ImportSpecifier */: + case 172 /* TypePredicate */: + case 182 /* UnionType */: + case 183 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 195 /* BindingElement */: + case 198 /* BindingElement */: // equals in type X = ... // falls through - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: // equal in let a = 0 // falls through - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: // equal in p = 0 // falls through - case 159 /* Parameter */: - case 288 /* EnumMember */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 160 /* Parameter */: + case 291 /* EnumMember */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: return context.currentTokenSpan.kind === 100 /* InKeyword */ || context.nextTokenSpan.kind === 100 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 236 /* ForOfStatement */: - return context.currentTokenSpan.kind === 155 /* OfKeyword */ || context.nextTokenSpan.kind === 155 /* OfKeyword */; + case 239 /* ForOfStatement */: + return context.currentTokenSpan.kind === 156 /* OfKeyword */ || context.nextTokenSpan.kind === 156 /* OfKeyword */; } return false; } @@ -127759,22 +130615,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 162 /* PropertyDeclaration */ || - contextKind === 161 /* PropertySignature */ || - contextKind === 159 /* Parameter */ || - contextKind === 246 /* VariableDeclaration */ || + return contextKind === 163 /* PropertyDeclaration */ || + contextKind === 162 /* PropertySignature */ || + contextKind === 160 /* Parameter */ || + contextKind === 249 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 214 /* ConditionalExpression */ || - context.contextNode.kind === 183 /* ConditionalType */; + return context.contextNode.kind === 217 /* ConditionalExpression */ || + context.contextNode.kind === 184 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 193 /* ObjectBindingPattern */ || - context.contextNode.kind === 189 /* MappedType */ || + return context.contextNode.kind === 196 /* ObjectBindingPattern */ || + context.contextNode.kind === 190 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -127800,34 +130656,34 @@ var ts; return true; } switch (node.kind) { - case 227 /* Block */: - case 255 /* CaseBlock */: - case 197 /* ObjectLiteralExpression */: - case 254 /* ModuleBlock */: + case 230 /* Block */: + case 258 /* CaseBlock */: + case 200 /* ObjectLiteralExpression */: + case 257 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 248 /* FunctionDeclaration */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 251 /* FunctionDeclaration */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 168 /* CallSignature */: - case 205 /* FunctionExpression */: - case 165 /* Constructor */: - case 206 /* ArrowFunction */: + case 169 /* CallSignature */: + case 208 /* FunctionExpression */: + case 166 /* Constructor */: + case 209 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 250 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 253 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -127836,40 +130692,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 248 /* FunctionDeclaration */ || context.contextNode.kind === 205 /* FunctionExpression */; + return context.contextNode.kind === 251 /* FunctionDeclaration */ || context.contextNode.kind === 208 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: - case 176 /* TypeLiteral */: - case 253 /* ModuleDeclaration */: - case 264 /* ExportDeclaration */: - case 265 /* NamedExports */: - case 258 /* ImportDeclaration */: - case 261 /* NamedImports */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: + case 177 /* TypeLiteral */: + case 256 /* ModuleDeclaration */: + case 267 /* ExportDeclaration */: + case 268 /* NamedExports */: + case 261 /* ImportDeclaration */: + case 264 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 249 /* ClassDeclaration */: - case 253 /* ModuleDeclaration */: - case 252 /* EnumDeclaration */: - case 284 /* CatchClause */: - case 254 /* ModuleBlock */: - case 241 /* SwitchStatement */: + case 252 /* ClassDeclaration */: + case 256 /* ModuleDeclaration */: + case 255 /* EnumDeclaration */: + case 287 /* CatchClause */: + case 257 /* ModuleBlock */: + case 244 /* SwitchStatement */: return true; - case 227 /* Block */: { + case 230 /* Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 206 /* ArrowFunction */ && blockParent.kind !== 205 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 209 /* ArrowFunction */ && blockParent.kind !== 208 /* FunctionExpression */) { return true; } } @@ -127878,32 +130734,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 231 /* IfStatement */: - case 241 /* SwitchStatement */: - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 233 /* WhileStatement */: - case 244 /* TryStatement */: - case 232 /* DoStatement */: - case 240 /* WithStatement */: + case 234 /* IfStatement */: + case 244 /* SwitchStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 236 /* WhileStatement */: + case 247 /* TryStatement */: + case 235 /* DoStatement */: + case 243 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 284 /* CatchClause */: + case 287 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 197 /* ObjectLiteralExpression */; + return context.contextNode.kind === 200 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 200 /* CallExpression */; + return context.contextNode.kind === 203 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 201 /* NewExpression */; + return context.contextNode.kind === 204 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -127918,10 +130774,10 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 206 /* ArrowFunction */; + return context.contextNode.kind === 209 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 192 /* ImportType */; + return context.contextNode.kind === 195 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; @@ -127930,19 +130786,19 @@ var ts; return context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 270 /* JsxElement */ && context.contextNode.kind !== 274 /* JsxFragment */; + return context.contextNode.kind !== 273 /* JsxElement */ && context.contextNode.kind !== 277 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 280 /* JsxExpression */ || context.contextNode.kind === 279 /* JsxSpreadAttribute */; + return context.contextNode.kind === 283 /* JsxExpression */ || context.contextNode.kind === 282 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 277 /* JsxAttribute */; + return context.nextTokenParent.kind === 280 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 277 /* JsxAttribute */; + return context.contextNode.kind === 280 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 271 /* JsxSelfClosingElement */; + return context.contextNode.kind === 274 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -127957,45 +130813,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 160 /* Decorator */; + return node.kind === 161 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 247 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 250 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 253 /* ModuleDeclaration */; + return context.contextNode.kind === 256 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 176 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 177 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 169 /* ConstructSignature */; + return context.contextNode.kind === 170 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 172 /* TypeReference */: - case 203 /* TypeAssertionExpression */: - case 251 /* TypeAliasDeclaration */: - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 200 /* CallExpression */: - case 201 /* NewExpression */: - case 220 /* ExpressionWithTypeArguments */: + case 173 /* TypeReference */: + case 206 /* TypeAssertionExpression */: + case 254 /* TypeAliasDeclaration */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: + case 223 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -128006,28 +130862,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 203 /* TypeAssertionExpression */; + return context.contextNode.kind === 206 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 113 /* VoidKeyword */ && context.currentTokenParent.kind === 209 /* VoidExpression */; + return context.currentTokenSpan.kind === 113 /* VoidKeyword */ && context.currentTokenParent.kind === 212 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 216 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 219 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 222 /* NonNullExpression */; + return context.contextNode.kind === 225 /* NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 231 /* IfStatement */: - case 234 /* ForStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 232 /* DoStatement */: - case 233 /* WhileStatement */: + case 234 /* IfStatement */: + case 237 /* ForStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 235 /* DoStatement */: + case 236 /* WhileStatement */: return true; default: return false; @@ -128052,12 +130908,12 @@ var ts; return nextTokenKind === 19 /* CloseBraceToken */ || nextTokenKind === 1 /* EndOfFileToken */; } - if (nextTokenKind === 226 /* SemicolonClassElement */ || + if (nextTokenKind === 229 /* SemicolonClassElement */ || nextTokenKind === 26 /* SemicolonToken */) { return false; } - if (context.contextNode.kind === 250 /* InterfaceDeclaration */ || - context.contextNode.kind === 251 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 253 /* InterfaceDeclaration */ || + context.contextNode.kind === 254 /* TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -128071,9 +130927,9 @@ var ts; if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 234 /* ForStatement */ - && context.currentTokenParent.kind !== 228 /* EmptyStatement */ - && context.currentTokenParent.kind !== 226 /* SemicolonClassElement */ + return context.currentTokenParent.kind !== 237 /* ForStatement */ + && context.currentTokenParent.kind !== 231 /* EmptyStatement */ + && context.currentTokenParent.kind !== 229 /* SemicolonClassElement */ && nextTokenKind !== 22 /* OpenBracketToken */ && nextTokenKind !== 20 /* OpenParenToken */ && nextTokenKind !== 39 /* PlusToken */ @@ -128081,7 +130937,7 @@ var ts; && nextTokenKind !== 43 /* SlashToken */ && nextTokenKind !== 13 /* RegularExpressionLiteral */ && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 215 /* TemplateExpression */ + && nextTokenKind !== 218 /* TemplateExpression */ && nextTokenKind !== 15 /* TemplateHead */ && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ && nextTokenKind !== 24 /* DotToken */; @@ -128172,12 +131028,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 155 /* LastKeyword */ && column <= 155 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 156 /* LastKeyword */ && column <= 156 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 155 /* LastToken */ + 1; + var mapRowLength = 156 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -128365,17 +131221,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 254 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 294 /* SourceFile */: - case 227 /* Block */: - case 254 /* ModuleBlock */: + return !!body && body.kind === 257 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 297 /* SourceFile */: + case 230 /* Block */: + case 257 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -128602,19 +131458,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 249 /* ClassDeclaration */: return 83 /* ClassKeyword */; - case 250 /* InterfaceDeclaration */: return 117 /* InterfaceKeyword */; - case 248 /* FunctionDeclaration */: return 97 /* FunctionKeyword */; - case 252 /* EnumDeclaration */: return 252 /* EnumDeclaration */; - case 166 /* GetAccessor */: return 134 /* GetKeyword */; - case 167 /* SetAccessor */: return 145 /* SetKeyword */; - case 164 /* MethodDeclaration */: + case 252 /* ClassDeclaration */: return 83 /* ClassKeyword */; + case 253 /* InterfaceDeclaration */: return 117 /* InterfaceKeyword */; + case 251 /* FunctionDeclaration */: return 97 /* FunctionKeyword */; + case 255 /* EnumDeclaration */: return 255 /* EnumDeclaration */; + case 167 /* GetAccessor */: return 134 /* GetKeyword */; + case 168 /* SetAccessor */: return 146 /* SetKeyword */; + case 165 /* MethodDeclaration */: if (node.asteriskToken) { return 41 /* AsteriskToken */; } // falls through - case 162 /* PropertyDeclaration */: - case 159 /* Parameter */: + case 163 /* PropertyDeclaration */: + case 160 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -128671,15 +131527,15 @@ var ts; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: switch (container.kind) { - case 272 /* JsxOpeningElement */: - case 273 /* JsxClosingElement */: - case 271 /* JsxSelfClosingElement */: + case 275 /* JsxOpeningElement */: + case 276 /* JsxClosingElement */: + case 274 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 189 /* MappedType */) { + if (container.kind !== 190 /* MappedType */) { return false; } break; @@ -128787,7 +131643,7 @@ var ts; return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 160 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 161 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 11 /* JsxText */) { @@ -128807,7 +131663,7 @@ var ts; } } childContextNode = node; - if (isFirstListItem && parent.kind === 196 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 199 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -129247,12 +132103,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 165 /* Constructor */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 206 /* ArrowFunction */: + case 166 /* Constructor */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 209 /* ArrowFunction */: if (node.typeParameters === list) { return 29 /* LessThanToken */; } @@ -129260,8 +132116,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 200 /* CallExpression */: - case 201 /* NewExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } @@ -129269,12 +132125,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 172 /* TypeReference */: + case 173 /* TypeReference */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } break; - case 176 /* TypeLiteral */: + case 177 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -129392,7 +132248,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 213 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 216 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -129546,7 +132402,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 294 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 297 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -129594,7 +132450,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 231 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 234 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 90 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -129632,40 +132488,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 172 /* TypeReference */: + case 173 /* TypeReference */: return getList(node.typeArguments); - case 197 /* ObjectLiteralExpression */: + case 200 /* ObjectLiteralExpression */: return getList(node.properties); - case 196 /* ArrayLiteralExpression */: + case 199 /* ArrayLiteralExpression */: return getList(node.elements); - case 176 /* TypeLiteral */: + case 177 /* TypeLiteral */: return getList(node.members); - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 168 /* CallSignature */: - case 165 /* Constructor */: - case 174 /* ConstructorType */: - case 169 /* ConstructSignature */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 169 /* CallSignature */: + case 166 /* Constructor */: + case 175 /* ConstructorType */: + case 170 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 326 /* JSDocTemplateTag */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 330 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 201 /* NewExpression */: - case 200 /* CallExpression */: + case 204 /* NewExpression */: + case 203 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 247 /* VariableDeclarationList */: + case 250 /* VariableDeclarationList */: return getList(node.declarations); - case 261 /* NamedImports */: - case 265 /* NamedExports */: + case 264 /* NamedImports */: + case 268 /* NamedExports */: return getList(node.elements); - case 193 /* ObjectBindingPattern */: - case 194 /* ArrayBindingPattern */: + case 196 /* ObjectBindingPattern */: + case 197 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -129688,7 +132544,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 247 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 250 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -129761,87 +132617,91 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 230 /* ExpressionStatement */: - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 196 /* ArrayLiteralExpression */: - case 227 /* Block */: - case 254 /* ModuleBlock */: - case 197 /* ObjectLiteralExpression */: - case 176 /* TypeLiteral */: - case 189 /* MappedType */: - case 178 /* TupleType */: - case 255 /* CaseBlock */: - case 282 /* DefaultClause */: - case 281 /* CaseClause */: - case 204 /* ParenthesizedExpression */: - case 198 /* PropertyAccessExpression */: - case 200 /* CallExpression */: - case 201 /* NewExpression */: - case 229 /* VariableStatement */: - case 263 /* ExportAssignment */: - case 239 /* ReturnStatement */: - case 214 /* ConditionalExpression */: - case 194 /* ArrayBindingPattern */: - case 193 /* ObjectBindingPattern */: - case 272 /* JsxOpeningElement */: - case 275 /* JsxOpeningFragment */: - case 271 /* JsxSelfClosingElement */: - case 280 /* JsxExpression */: - case 163 /* MethodSignature */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 159 /* Parameter */: - case 173 /* FunctionType */: - case 174 /* ConstructorType */: - case 185 /* ParenthesizedType */: - case 202 /* TaggedTemplateExpression */: - case 210 /* AwaitExpression */: - case 265 /* NamedExports */: - case 261 /* NamedImports */: - case 267 /* ExportSpecifier */: - case 262 /* ImportSpecifier */: - case 162 /* PropertyDeclaration */: + case 233 /* ExpressionStatement */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 199 /* ArrayLiteralExpression */: + case 230 /* Block */: + case 257 /* ModuleBlock */: + case 200 /* ObjectLiteralExpression */: + case 177 /* TypeLiteral */: + case 190 /* MappedType */: + case 179 /* TupleType */: + case 258 /* CaseBlock */: + case 285 /* DefaultClause */: + case 284 /* CaseClause */: + case 207 /* ParenthesizedExpression */: + case 201 /* PropertyAccessExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: + case 232 /* VariableStatement */: + case 266 /* ExportAssignment */: + case 242 /* ReturnStatement */: + case 217 /* ConditionalExpression */: + case 197 /* ArrayBindingPattern */: + case 196 /* ObjectBindingPattern */: + case 275 /* JsxOpeningElement */: + case 278 /* JsxOpeningFragment */: + case 274 /* JsxSelfClosingElement */: + case 283 /* JsxExpression */: + case 164 /* MethodSignature */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 160 /* Parameter */: + case 174 /* FunctionType */: + case 175 /* ConstructorType */: + case 186 /* ParenthesizedType */: + case 205 /* TaggedTemplateExpression */: + case 213 /* AwaitExpression */: + case 268 /* NamedExports */: + case 264 /* NamedImports */: + case 270 /* ExportSpecifier */: + case 265 /* ImportSpecifier */: + case 163 /* PropertyDeclaration */: return true; - case 246 /* VariableDeclaration */: - case 285 /* PropertyAssignment */: - case 213 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 197 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 249 /* VariableDeclaration */: + case 288 /* PropertyAssignment */: + case 216 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 200 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind !== 213 /* BinaryExpression */) { + if (parent.kind !== 216 /* BinaryExpression */) { return true; } break; - case 232 /* DoStatement */: - case 233 /* WhileStatement */: - case 235 /* ForInStatement */: - case 236 /* ForOfStatement */: - case 234 /* ForStatement */: - case 231 /* IfStatement */: - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 164 /* MethodDeclaration */: - case 206 /* ArrowFunction */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - return childKind !== 227 /* Block */; - case 264 /* ExportDeclaration */: - return childKind !== 265 /* NamedExports */; - case 258 /* ImportDeclaration */: - return childKind !== 259 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 261 /* NamedImports */); - case 270 /* JsxElement */: - return childKind !== 273 /* JsxClosingElement */; - case 274 /* JsxFragment */: - return childKind !== 276 /* JsxClosingFragment */; - case 182 /* IntersectionType */: - case 181 /* UnionType */: - if (childKind === 176 /* TypeLiteral */ || childKind === 178 /* TupleType */) { + case 235 /* DoStatement */: + case 236 /* WhileStatement */: + case 238 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 237 /* ForStatement */: + case 234 /* IfStatement */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 165 /* MethodDeclaration */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + return childKind !== 230 /* Block */; + case 209 /* ArrowFunction */: + if (sourceFile && childKind === 207 /* ParenthesizedExpression */) { + return rangeIsOnOneLine(sourceFile, child); + } + return childKind !== 230 /* Block */; + case 267 /* ExportDeclaration */: + return childKind !== 268 /* NamedExports */; + case 261 /* ImportDeclaration */: + return childKind !== 262 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 264 /* NamedImports */); + case 273 /* JsxElement */: + return childKind !== 276 /* JsxClosingElement */; + case 277 /* JsxFragment */: + return childKind !== 279 /* JsxClosingFragment */; + case 183 /* IntersectionType */: + case 182 /* UnionType */: + if (childKind === 177 /* TypeLiteral */ || childKind === 179 /* TupleType */) { return false; } // falls through @@ -129852,11 +132712,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 239 /* ReturnStatement */: - case 243 /* ThrowStatement */: - case 237 /* ContinueStatement */: - case 238 /* BreakStatement */: - return parent.kind !== 227 /* Block */; + case 242 /* ReturnStatement */: + case 246 /* ThrowStatement */: + case 240 /* ContinueStatement */: + case 241 /* BreakStatement */: + return parent.kind !== 230 /* Block */; default: return false; } @@ -129930,8 +132790,10 @@ var ts; (function (TrailingTriviaOption) { /** Exclude all trailing trivia (use getEnd()) */ TrailingTriviaOption[TrailingTriviaOption["Exclude"] = 0] = "Exclude"; + /** Doesn't include whitespace, but does strip comments */ + TrailingTriviaOption[TrailingTriviaOption["ExcludeWhitespace"] = 1] = "ExcludeWhitespace"; /** Include trailing trivia */ - TrailingTriviaOption[TrailingTriviaOption["Include"] = 1] = "Include"; + TrailingTriviaOption[TrailingTriviaOption["Include"] = 2] = "Include"; })(TrailingTriviaOption = textChanges_3.TrailingTriviaOption || (textChanges_3.TrailingTriviaOption = {})); function skipWhitespacesAndLineBreaks(text, start) { return ts.skipTrivia(text, start, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); @@ -130002,9 +132864,18 @@ var ts; return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); } function getAdjustedEndPosition(sourceFile, node, options) { + var _a; var end = node.end; var trailingTriviaOption = options.trailingTriviaOption; - if (trailingTriviaOption === TrailingTriviaOption.Exclude || (ts.isExpression(node) && trailingTriviaOption !== TrailingTriviaOption.Include)) { + if (trailingTriviaOption === TrailingTriviaOption.Exclude) { + return end; + } + if (trailingTriviaOption === TrailingTriviaOption.ExcludeWhitespace) { + var comments = ts.concatenate(ts.getTrailingCommentRanges(sourceFile.text, end), ts.getLeadingCommentRanges(sourceFile.text, end)); + var realEnd = (_a = comments === null || comments === void 0 ? void 0 : comments[comments.length - 1]) === null || _a === void 0 ? void 0 : _a.end; + if (realEnd) { + return realEnd; + } return end; } var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); @@ -130016,7 +132887,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 197 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 200 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -130220,7 +133091,7 @@ var ts; } } else { - endNode = (_a = (node.kind === 246 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 249 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; @@ -130377,18 +133248,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 249 /* ClassDeclaration */: - case 253 /* ModuleDeclaration */: + case 252 /* ClassDeclaration */: + case 256 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: case 10 /* StringLiteral */: case 78 /* Identifier */: return { prefix: ", " }; - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; case 92 /* ExportKeyword */: return { prefix: " " }; - case 159 /* Parameter */: + case 160 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -130397,7 +133268,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 206 /* ArrowFunction */) { + if (node.kind === 209 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { @@ -130411,14 +133282,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 227 /* Block */) { + if (node.body.kind !== 230 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(104 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 205 /* FunctionExpression */ ? 97 /* FunctionKeyword */ : 83 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 208 /* FunctionExpression */ ? 97 /* FunctionKeyword */ : 83 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -130714,7 +133585,12 @@ var ts; function getNonformattedText(node, sourceFile, newLineCharacter) { var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, preserveSourceNewlines: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ + newLine: newLine, + neverAsciiEscape: true, + preserveSourceNewlines: true, + terminateUnterminatedLiterals: true + }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -130988,14 +133864,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 157 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 158 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 159 /* Parameter */: { + case 160 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -131010,15 +133886,15 @@ var ts; } break; } - case 258 /* ImportDeclaration */: - case 257 /* ImportEqualsDeclaration */: + case 261 /* ImportDeclaration */: + case 260 /* ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; - case 195 /* BindingElement */: + case 198 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 194 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 197 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -131026,13 +133902,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 158 /* TypeParameter */: + case 159 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -131041,7 +133917,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 260 /* NamespaceImport */: + case 263 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; case 26 /* SemicolonToken */: @@ -131050,8 +133926,8 @@ var ts; case 97 /* FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 249 /* ClassDeclaration */: - case 248 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 251 /* FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -131098,13 +133974,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 258 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 261 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 284 /* CatchClause */) { + if (parent.kind === 287 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -131115,14 +133991,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 236 /* ForOfStatement */: - case 235 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 238 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 234 /* ForStatement */: + case 237 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -131301,8 +134177,8 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(151 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(151 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -131531,7 +134407,7 @@ var ts; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 229 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 232 /* VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || @@ -131609,10 +134485,10 @@ var ts; function isInsideAwaitableBody(node) { return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 248 /* FunctionDeclaration */ || - ancestor.parent.kind === 205 /* FunctionExpression */ || - ancestor.parent.kind === 206 /* ArrowFunction */ || - ancestor.parent.kind === 164 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 251 /* FunctionDeclaration */ || + ancestor.parent.kind === 208 /* FunctionExpression */ || + ancestor.parent.kind === 209 /* ArrowFunction */ || + ancestor.parent.kind === 165 /* MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -131731,10 +134607,10 @@ var ts; function isPossiblyPartOfDestructuring(node) { switch (node.kind) { case 78 /* Identifier */: - case 196 /* ArrayLiteralExpression */: - case 197 /* ObjectLiteralExpression */: - case 285 /* PropertyAssignment */: - case 286 /* ShorthandPropertyAssignment */: + case 199 /* ArrayLiteralExpression */: + case 200 /* ObjectLiteralExpression */: + case 288 /* PropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -131749,7 +134625,7 @@ var ts; function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { case 78 /* Identifier */: - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -131798,7 +134674,7 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 162 /* PropertyDeclaration */ && + if (declaration.kind === 163 /* PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { changeTracker.insertModifierBefore(sourceFile, 133 /* DeclareKeyword */, declaration); } @@ -131935,26 +134811,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 246 /* VariableDeclaration */ || - node.kind === 161 /* PropertySignature */ || - node.kind === 162 /* PropertyDeclaration */; + node.kind === 249 /* VariableDeclaration */ || + node.kind === 162 /* PropertySignature */ || + node.kind === 163 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 299 /* JSDocAllType */: - case 300 /* JSDocUnknownType */: + case 303 /* JSDocAllType */: + case 304 /* JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 303 /* JSDocOptionalType */: + case 307 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 302 /* JSDocNonNullableType */: + case 306 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 301 /* JSDocNullableType */: + case 305 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 305 /* JSDocVariadicType */: + case 309 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 304 /* JSDocFunctionType */: + case 308 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 172 /* TypeReference */: + case 173 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); @@ -131979,7 +134855,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 305 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 309 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -132019,8 +134895,8 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 143 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 143 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -132149,7 +135025,7 @@ var ts; return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 230 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 233 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -132205,7 +135081,7 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 227 /* Block */) { + if (arrowFunctionBody.kind === 230 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -132400,7 +135276,7 @@ var ts; // will eventually become // const response = await fetch('...') // so we push an entry for 'response'. - if (lastCallSignature && !ts.isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) { + if (lastCallSignature && !ts.isParameter(node.parent) && !ts.isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) { var firstParameter = ts.firstOrUndefined(lastCallSignature.parameters); var ident = firstParameter && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) || ts.factory.createUniqueName("result", 16 /* Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); @@ -132426,7 +135302,22 @@ var ts; } } }); - return ts.getSynthesizedDeepCloneWithRenames(nodeToRename, /*includeTrivia*/ true, identsToRenameMap, checker); + return ts.getSynthesizedDeepCloneWithReplacements(nodeToRename, /*includeTrivia*/ true, function (original) { + if (ts.isBindingElement(original) && ts.isIdentifier(original.name) && ts.isObjectBindingPattern(original.parent)) { + var symbol = checker.getSymbolAtLocation(original.name); + var renameInfo = symbol && identsToRenameMap.get(String(ts.getSymbolId(symbol))); + if (renameInfo && renameInfo.text !== (original.name || original.propertyName).getText()) { + return ts.factory.createBindingElement(original.dotDotDotToken, original.propertyName || original.name, renameInfo, original.initializer); + } + } + else if (ts.isIdentifier(original)) { + var symbol = checker.getSymbolAtLocation(original); + var renameInfo = symbol && identsToRenameMap.get(String(ts.getSymbolId(symbol))); + if (renameInfo) { + return ts.factory.createIdentifier(renameInfo.text); + } + } + }); } function getNewNameIfConflict(name, originalNames) { var numVarsSameName = (originalNames.get(name.text) || ts.emptyArray).length; @@ -132507,7 +135398,7 @@ var ts; } var tryStatement = ts.factory.createTryStatement(tryBlock, catchClause, /*finallyBlock*/ undefined); var destructuredResult = prevArgName && varDeclIdentifier && isSynthBindingPattern(prevArgName) - && ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.getSynthesizedDeepCloneWithRenames(prevArgName.bindingPattern), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier)], 2 /* Const */)); + && ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(prevArgName.bindingPattern), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier)], 2 /* Const */)); return ts.compact([varDeclList, tryStatement, destructuredResult]); } function createUniqueSynthName(prevArgName) { @@ -132566,7 +135457,7 @@ var ts; } // should be kept up to date with isFixablePromiseArgument in suggestionDiagnostics.ts function getTransformationBody(func, prevArgName, argName, parent, transformer) { - var _a, _b, _c, _d; + var _a, _b, _c, _d, _e; switch (func.kind) { case 103 /* NullKeyword */: // do not produce a transformed statement for a null argument @@ -132592,22 +135483,24 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: { + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: { var funcBody = func.body; + var returnType_1 = (_c = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _c === void 0 ? void 0 : _c.getReturnType(); // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { var refactoredStmts = []; var seenReturnStatement = false; - for (var _i = 0, _e = funcBody.statements; _i < _e.length; _i++) { - var statement = _e[_i]; + for (var _i = 0, _f = funcBody.statements; _i < _f.length; _i++) { + var statement = _f[_i]; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); } else { - refactoredStmts.push.apply(refactoredStmts, maybeAnnotateAndReturn(statement.expression, (_c = parent.typeArguments) === null || _c === void 0 ? void 0 : _c[0])); + var possiblyAwaitedRightHandSide = returnType_1 && statement.expression ? getPossiblyAwaitedRightHandSide(transformer.checker, returnType_1, statement.expression) : statement.expression; + refactoredStmts.push.apply(refactoredStmts, maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, (_d = parent.typeArguments) === null || _d === void 0 ? void 0 : _d[0])); } } else { @@ -132624,19 +135517,21 @@ var ts; if (innerCbBody.length > 0) { return innerCbBody; } - var type_1 = transformer.checker.getTypeAtLocation(func); - var returnType_1 = getLastCallSignature(type_1, transformer.checker).getReturnType(); - var rightHandSide = ts.getSynthesizedDeepClone(funcBody); - var possiblyAwaitedRightHandSide = !!transformer.checker.getPromisedTypeOfPromise(returnType_1) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; - if (!shouldReturn(parent, transformer)) { - var transformedStatement = createVariableOrAssignmentOrExpressionStatement(prevArgName, possiblyAwaitedRightHandSide, /*typeAnnotation*/ undefined); - if (prevArgName) { - prevArgName.types.push(returnType_1); + if (returnType_1) { + var possiblyAwaitedRightHandSide = getPossiblyAwaitedRightHandSide(transformer.checker, returnType_1, funcBody); + if (!shouldReturn(parent, transformer)) { + var transformedStatement = createVariableOrAssignmentOrExpressionStatement(prevArgName, possiblyAwaitedRightHandSide, /*typeAnnotation*/ undefined); + if (prevArgName) { + prevArgName.types.push(returnType_1); + } + return transformedStatement; + } + else { + return maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, (_e = parent.typeArguments) === null || _e === void 0 ? void 0 : _e[0]); } - return transformedStatement; } else { - return maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, (_d = parent.typeArguments) === null || _d === void 0 ? void 0 : _d[0]); + return silentFail(); } } } @@ -132646,6 +135541,10 @@ var ts; } return ts.emptyArray; } + function getPossiblyAwaitedRightHandSide(checker, type, expr) { + var rightHandSide = ts.getSynthesizedDeepClone(expr); + return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; + } function getLastCallSignature(type, checker) { var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */); return ts.lastOrUndefined(callSignatures); @@ -132801,10 +135700,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 200 /* CallExpression */: + case 203 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -132818,11 +135717,25 @@ var ts; var exports = collectExportRenames(sourceFile, checker, identifiers); convertExportsAccesses(sourceFile, exports, changes); var moduleExportsChangedToDefault = false; - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var useSitesToUnqualify; + // Process variable statements first to collect use sites that need to be updated inside other transformations + for (var _i = 0, _a = ts.filter(sourceFile.statements, ts.isVariableStatement); _i < _a.length; _i++) { var statement = _a[_i]; - var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference); + var newUseSites = convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); + if (newUseSites) { + ts.copyEntries(newUseSites, useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())); + } + } + // `convertStatement` will delete entries from `useSitesToUnqualify` when containing statements are replaced + for (var _b = 0, _c = ts.filter(sourceFile.statements, function (s) { return !ts.isVariableStatement(s); }); _b < _c.length; _b++) { + var statement = _c[_b]; + var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference); moduleExportsChangedToDefault = moduleExportsChangedToDefault || moduleExportsChanged; } + // Remaining use sites can be changed directly + useSitesToUnqualify === null || useSitesToUnqualify === void 0 ? void 0 : useSitesToUnqualify.forEach(function (replacement, original) { + changes.replaceNode(sourceFile, original, replacement); + }); return moduleExportsChangedToDefault; } function collectExportRenames(sourceFile, checker, identifiers) { @@ -132855,24 +135768,24 @@ var ts; node.forEachChild(recur); }); } - function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { + function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 230 /* ExpressionStatement */: { + case 233 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 200 /* CallExpression */: { + case 203 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 213 /* BinaryExpression */: { + case 216 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -132884,17 +135797,17 @@ var ts; function convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference) { var declarationList = statement.declarationList; var foundImport = false; - var newNodes = ts.flatMap(declarationList.declarations, function (decl) { + var converted = ts.map(declarationList.declarations, function (decl) { var name = decl.name, initializer = decl.initializer; if (initializer) { if (ts.isExportsOrModuleExportsOrAlias(sourceFile, initializer)) { // `const alias = module.exports;` can be removed. foundImport = true; - return []; + return convertedImports([]); } else if (ts.isRequireCall(initializer, /*checkArgumentIsStringLiteralLike*/ true)) { foundImport = true; - return convertSingleImport(sourceFile, name, initializer.arguments[0], changes, checker, identifiers, target, quotePreference); + return convertSingleImport(name, initializer.arguments[0], checker, identifiers, target, quotePreference); } else if (ts.isPropertyAccessExpression(initializer) && ts.isRequireCall(initializer.expression, /*checkArgumentIsStringLiteralLike*/ true)) { foundImport = true; @@ -132902,33 +135815,40 @@ var ts; } } // Move it out to its own variable statement. (This will not be used if `!foundImport`) - return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([decl], declarationList.flags)); + return convertedImports([ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([decl], declarationList.flags))]); }); if (foundImport) { // useNonAdjustedEndPosition to ensure we don't eat the newline after the statement. - changes.replaceNodeWithNodes(sourceFile, statement, newNodes); + changes.replaceNodeWithNodes(sourceFile, statement, ts.flatMap(converted, function (c) { return c.newImports; })); + var combinedUseSites_1; + ts.forEach(converted, function (c) { + if (c.useSitesToUnqualify) { + ts.copyEntries(c.useSitesToUnqualify, combinedUseSites_1 !== null && combinedUseSites_1 !== void 0 ? combinedUseSites_1 : (combinedUseSites_1 = new ts.Map())); + } + }); + return combinedUseSites_1; } } /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 193 /* ObjectBindingPattern */: - case 194 /* ArrayBindingPattern */: { + case 196 /* ObjectBindingPattern */: + case 197 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); - return [ + return convertedImports([ makeSingleImport(tmp, propertyName, moduleSpecifier, quotePreference), makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), - ]; + ]); } case 78 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; - return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; + return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } - function convertAssignment(sourceFile, checker, assignment, changes, exports) { + function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { var left = assignment.left, right = assignment.right; if (!ts.isPropertyAccessExpression(left)) { return false; @@ -132939,7 +135859,7 @@ var ts; changes.delete(sourceFile, assignment.parent); } else { - var replacement = ts.isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right) + var replacement = ts.isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right, useSitesToUnqualify) : ts.isRequireCall(right, /*checkArgumentIsStringLiteralLike*/ true) ? convertReExportAll(right.arguments[0], checker) : undefined; if (replacement) { @@ -132961,20 +135881,20 @@ var ts; * Convert `module.exports = { ... }` to individual exports.. * We can't always do this if the module has interesting members -- then it will be a default export instead. */ - function tryChangeModuleExportsObject(object) { + function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 286 /* ShorthandPropertyAssignment */: - case 287 /* SpreadAssignment */: + case 289 /* ShorthandPropertyAssignment */: + case 290 /* SpreadAssignment */: return undefined; - case 285 /* PropertyAssignment */: - return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 164 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(92 /* ExportKeyword */)], prop); + case 288 /* PropertyAssignment */: + return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); + case 165 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(92 /* ExportKeyword */)], prop, useSitesToUnqualify); default: ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } @@ -133034,10 +135954,10 @@ var ts; } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. - function convertExportsDotXEquals_replaceNode(name, exported) { + function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { var modifiers = [ts.factory.createToken(92 /* ExportKeyword */)]; switch (exported.kind) { - case 205 /* FunctionExpression */: { + case 208 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -133045,18 +135965,35 @@ var ts; } } // falls through - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` - return functionExpressionToDeclaration(name, modifiers, exported); - case 218 /* ClassExpression */: + return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); + case 221 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` - return classExpressionToDeclaration(name, modifiers, exported); + return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: return exportConst(); } function exportConst() { // `exports.x = 0;` --> `export const x = 0;` - return makeConst(modifiers, ts.factory.createIdentifier(name), exported); // TODO: GH#18217 + return makeConst(modifiers, ts.factory.createIdentifier(name), replaceImportUseSites(exported, useSitesToUnqualify)); // TODO: GH#18217 + } + } + function replaceImportUseSites(nodeOrNodes, useSitesToUnqualify) { + if (!useSitesToUnqualify || !ts.some(ts.arrayFrom(useSitesToUnqualify.keys()), function (original) { return ts.rangeContainsRange(nodeOrNodes, original); })) { + return nodeOrNodes; + } + return ts.isArray(nodeOrNodes) + ? ts.getSynthesizedDeepClonesWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode) + : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); + function replaceNode(original) { + // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions + if (original.kind === 201 /* PropertyAccessExpression */) { + var replacement = useSitesToUnqualify.get(original); + // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing + useSitesToUnqualify.delete(original); + return replacement; + } } } /** @@ -133064,9 +136001,9 @@ var ts; * Returns nodes that will replace the variable declaration for the commonjs import. * May also make use `changes` to remove qualifiers at the use sites of imports, to change `mod.x` to `x`. */ - function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { + function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 193 /* ObjectBindingPattern */: { + case 196 /* ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -133075,23 +136012,23 @@ var ts; : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); }); if (importSpecifiers) { - return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; + return convertedImports([ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]); } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 194 /* ArrayBindingPattern */: { + case 197 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; */ var tmp = makeUniqueName(codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, target), identifiers); - return [ + return convertedImports([ ts.makeImport(ts.factory.createIdentifier(tmp), /*namedImports*/ undefined, moduleSpecifier, quotePreference), makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), - ]; + ]); } case 78 /* Identifier */: - return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); + return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } @@ -133100,12 +136037,13 @@ var ts; * Convert `import x = require("x").` * Also converts uses like `x.y()` to `y()` and uses a named import. */ - function convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference) { + function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); // Maps from module property name to name actually used. (The same if there isn't shadowing.) var namedBindingsNames = new ts.Map(); // True if there is some non-property use like `x()` or `f(x)`. var needDefaultImport = false; + var useSitesToUnqualify; for (var _i = 0, _a = identifiers.original.get(name.text); _i < _a.length; _i++) { var use = _a[_i]; if (checker.getSymbolAtLocation(use) !== nameSymbol || use === name) { @@ -133121,7 +136059,7 @@ var ts; idName = makeUniqueName(propertyName, identifiers); namedBindingsNames.set(propertyName, idName); } - changes.replaceNode(file, parent, ts.factory.createIdentifier(idName)); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -133135,7 +136073,7 @@ var ts; // If it was unused, ensure that we at least import *something*. needDefaultImport = true; } - return [ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier, quotePreference)]; + return convertedImports([ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier, quotePreference)], useSitesToUnqualify); } // Identifiers helpers function makeUniqueName(name, identifiers) { @@ -133162,24 +136100,24 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: return parent.name !== node; - case 195 /* BindingElement */: + case 198 /* BindingElement */: return parent.propertyName !== node; - case 262 /* ImportSpecifier */: + case 265 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; } } // Node helpers - function functionExpressionToDeclaration(name, additionalModifiers, fn) { + function functionExpressionToDeclaration(name, additionalModifiers, fn, useSitesToUnqualify) { return ts.factory.createFunctionDeclaration(ts.getSynthesizedDeepClones(fn.decorators), // TODO: GH#19915 Don't think this is even legal. - ts.concatenate(additionalModifiers, ts.getSynthesizedDeepClones(fn.modifiers)), ts.getSynthesizedDeepClone(fn.asteriskToken), name, ts.getSynthesizedDeepClones(fn.typeParameters), ts.getSynthesizedDeepClones(fn.parameters), ts.getSynthesizedDeepClone(fn.type), ts.factory.converters.convertToFunctionBlock(ts.getSynthesizedDeepClone(fn.body))); + ts.concatenate(additionalModifiers, ts.getSynthesizedDeepClones(fn.modifiers)), ts.getSynthesizedDeepClone(fn.asteriskToken), name, ts.getSynthesizedDeepClones(fn.typeParameters), ts.getSynthesizedDeepClones(fn.parameters), ts.getSynthesizedDeepClone(fn.type), ts.factory.converters.convertToFunctionBlock(replaceImportUseSites(fn.body, useSitesToUnqualify))); } - function classExpressionToDeclaration(name, additionalModifiers, cls) { + function classExpressionToDeclaration(name, additionalModifiers, cls, useSitesToUnqualify) { return ts.factory.createClassDeclaration(ts.getSynthesizedDeepClones(cls.decorators), // TODO: GH#19915 Don't think this is even legal. - ts.concatenate(additionalModifiers, ts.getSynthesizedDeepClones(cls.modifiers)), name, ts.getSynthesizedDeepClones(cls.typeParameters), ts.getSynthesizedDeepClones(cls.heritageClauses), ts.getSynthesizedDeepClones(cls.members)); + ts.concatenate(additionalModifiers, ts.getSynthesizedDeepClones(cls.modifiers)), name, ts.getSynthesizedDeepClones(cls.typeParameters), ts.getSynthesizedDeepClones(cls.heritageClauses), replaceImportUseSites(cls.members, useSitesToUnqualify)); } function makeSingleImport(localName, propertyName, moduleSpecifier, quotePreference) { return propertyName === "default" @@ -133198,6 +136136,12 @@ var ts; /*modifiers*/ undefined, /*isTypeOnly*/ false, exportSpecifiers && ts.factory.createNamedExports(exportSpecifiers), moduleSpecifier === undefined ? undefined : ts.factory.createStringLiteral(moduleSpecifier)); } + function convertedImports(newImports, useSitesToUnqualify) { + return { + newImports: newImports, + useSitesToUnqualify: useSitesToUnqualify + }; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -133257,7 +136201,7 @@ var ts; var fixedExportDeclarations = new ts.Map(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { var exportSpecifier = getExportSpecifierForDiagnosticSpan(diag, context.sourceFile); - if (exportSpecifier && !ts.addToSeen(fixedExportDeclarations, ts.getNodeId(exportSpecifier.parent.parent))) { + if (exportSpecifier && ts.addToSeen(fixedExportDeclarations, ts.getNodeId(exportSpecifier.parent.parent))) { fixSingleExportDeclaration(changes, exportSpecifier, context); } }); @@ -133274,8 +136218,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.replaceNode(context.sourceFile, exportDeclaration, ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, - /*isTypeOnly*/ true, exportClause, exportDeclaration.moduleSpecifier)); + changes.insertModifierBefore(context.sourceFile, 149 /* TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -133284,7 +136227,10 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ true, ts.factory.createNamedExports(typeExportSpecifiers), exportDeclaration.moduleSpecifier); - changes.replaceNode(context.sourceFile, exportDeclaration, valueExportDeclaration); + changes.replaceNode(context.sourceFile, exportDeclaration, valueExportDeclaration, { + leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Exclude + }); changes.insertNodeAfter(context.sourceFile, exportDeclaration, typeExportDeclaration); } } @@ -133354,6 +136300,53 @@ var ts; (function (ts) { var codefix; (function (codefix) { + var fixId = "convertLiteralTypeToMappedType"; + var errorCodes = [ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span; + var info = getInfo(sourceFile, span.start); + if (!info) { + return undefined; + } + var name = info.name, constraint = info.constraint; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Convert_0_to_1_in_0, constraint, name], fixId, ts.Diagnostics.Convert_all_type_literals_to_mapped_type)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, diag.start); + if (info) { + doChange(changes, diag.file, info); + } + }); } + }); + function getInfo(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + if (ts.isIdentifier(token)) { + var propertySignature = ts.cast(token.parent.parent, ts.isPropertySignature); + var propertyName = token.getText(sourceFile); + return { + container: ts.cast(propertySignature.parent, ts.isTypeLiteralNode), + typeNode: propertySignature.type, + constraint: propertyName, + name: propertyName === "K" ? "P" : "K", + }; + } + return undefined; + } + function doChange(changes, sourceFile, _a) { + var container = _a.container, typeNode = _a.typeNode, constraint = _a.constraint, name = _a.name; + changes.replaceNode(sourceFile, container, ts.factory.createMappedTypeNode(/*readonlyToken*/ undefined, ts.factory.createTypeParameterDeclaration(name, ts.factory.createTypeReferenceNode(constraint)), /*nameType*/ undefined, /*questionToken*/ undefined, typeNode)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { var errorCodes = [ ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code @@ -133495,7 +136488,7 @@ var ts; var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker)); var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, useAutoImportProvider); var preferTypeOnlyImport = !!usageIsTypeOnly && compilerOptions.importsNotUsedAsValues === 2 /* Error */; - var useRequire = shouldUseRequire(sourceFile, compilerOptions); + var useRequire = shouldUseRequire(sourceFile, program); var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, preferTypeOnlyImport, useRequire, host, preferences); addImport({ fixes: [fix], symbolName: symbolName }); } @@ -133598,7 +136591,7 @@ var ts; function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var compilerOptions = program.getCompilerOptions(); var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, /*useAutoImportProvider*/ true); - var useRequire = shouldUseRequire(sourceFile, compilerOptions); + var useRequire = shouldUseRequire(sourceFile, program); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !ts.isSourceFileJS(sourceFile) && ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences)).moduleSpecifier; var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences); @@ -133624,7 +136617,7 @@ var ts; return; } var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); - if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { @@ -133680,11 +136673,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -133694,11 +136687,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return declaration.name.text; - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -133707,10 +136700,10 @@ var ts; function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 257 /* ImportEqualsDeclaration */) + if (declaration.kind === 260 /* ImportEqualsDeclaration */) return undefined; - if (declaration.kind === 246 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 193 /* ObjectBindingPattern */ + if (declaration.kind === 249 /* VariableDeclaration */) { + return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 196 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, canUseTypeOnlyImport: false } : undefined; } @@ -133718,7 +136711,7 @@ var ts; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 261 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 264 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.getText(), canUseTypeOnlyImport: canUseTypeOnlyImport } : undefined; }); @@ -133731,15 +136724,38 @@ var ts; if (ts.isRequireVariableDeclaration(i.parent, /*requireStringLiteralLikeArgument*/ true)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined; } - if (i.kind === 258 /* ImportDeclaration */ || i.kind === 257 /* ImportEqualsDeclaration */) { + if (i.kind === 261 /* ImportDeclaration */ || i.kind === 260 /* ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; } }); } - function shouldUseRequire(sourceFile, compilerOptions) { - return ts.isSourceFileJS(sourceFile) - && !sourceFile.externalModuleIndicator - && (!!sourceFile.commonJsModuleIndicator || ts.getEmitModuleKind(compilerOptions) < ts.ModuleKind.ES2015); + function shouldUseRequire(sourceFile, program) { + // 1. TypeScript files don't use require variable declarations + if (!ts.isSourceFileJS(sourceFile)) { + return false; + } + // 2. If the current source file is unambiguously CJS or ESM, go with that + if (sourceFile.commonJsModuleIndicator && !sourceFile.externalModuleIndicator) + return true; + if (sourceFile.externalModuleIndicator && !sourceFile.commonJsModuleIndicator) + return false; + // 3. If there's a tsconfig/jsconfig, use its module setting + var compilerOptions = program.getCompilerOptions(); + if (compilerOptions.configFile) { + return ts.getEmitModuleKind(compilerOptions) < ts.ModuleKind.ES2015; + } + // 4. Match the first other JS file in the program that's unambiguously CJS or ESM + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var otherFile = _a[_i]; + if (otherFile === sourceFile || !ts.isSourceFileJS(otherFile) || program.isSourceFileFromExternalLibrary(otherFile)) + continue; + if (otherFile.commonJsModuleIndicator && !otherFile.externalModuleIndicator) + return true; + if (otherFile.externalModuleIndicator && !otherFile.commonJsModuleIndicator) + return false; + } + // 5. Literally nothing to go on + return true; } function getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); @@ -133774,9 +136790,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) { var declaration = _a.declaration, importKind = _a.importKind; - var moduleSpecifier = declaration.kind === 258 /* ImportDeclaration */ ? declaration.moduleSpecifier : - declaration.kind === 246 /* VariableDeclaration */ ? declaration.initializer.arguments[0] : - declaration.moduleReference.kind === 269 /* ExternalModuleReference */ ? declaration.moduleReference.expression : + var moduleSpecifier = declaration.kind === 261 /* ImportDeclaration */ ? declaration.moduleSpecifier : + declaration.kind === 249 /* VariableDeclaration */ ? declaration.initializer.arguments[0] : + declaration.moduleReference.kind === 272 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier.text, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } @@ -133798,7 +136814,7 @@ var ts; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; - var useRequire = shouldUseRequire(sourceFile, program.getCompilerOptions()); + var useRequire = shouldUseRequire(sourceFile, program); var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } @@ -133847,8 +136863,8 @@ var ts; ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); var compilerOptions = program.getCompilerOptions(); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && ts.isValidTypeOnlyAliasUseSite(symbolToken); - var useRequire = shouldUseRequire(sourceFile, compilerOptions); - var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, useAutoImportProvider, host); + var useRequire = shouldUseRequire(sourceFile, program); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); @@ -133866,23 +136882,25 @@ var ts; return symbolToken.text; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, useAutoImportProvider, host) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, program, useAutoImportProvider, host) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); - function addSymbol(moduleSymbol, exportedSymbol, importKind) { + function addSymbol(moduleSymbol, exportedSymbol, importKind, checker) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, useAutoImportProvider, function (moduleSymbol) { + forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, useAutoImportProvider, function (moduleSymbol, _, program) { + var checker = program.getTypeChecker(); cancellationToken.throwIfCancellationRequested(); - var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); - if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { - addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind); + var compilerOptions = program.getCompilerOptions(); + var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, compilerOptions); + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { + addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind, checker); } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); + addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */, checker); } }); return originalSymbolToExportInfos; @@ -133936,7 +136954,13 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.checkDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); + if (aliased && aliased.parent) { + // - `aliased` will be undefined if the module is exporting an unresolvable name, + // but we can still offer completions for it. + // - `aliased.parent` will be undefined if the module is exporting `globalThis.something`, + // or another expression that resolves to a global. + return getDefaultExportInfoWorker(aliased, aliased.parent, checker, compilerOptions); + } } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -133992,7 +137016,7 @@ var ts; } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) { - if (clause.kind === 193 /* ObjectBindingPattern */) { + if (clause.kind === 196 /* ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport, "default"); } @@ -134399,7 +137423,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 191 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 192 /* NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -134408,11 +137432,11 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 179 /* OptionalType */ || unwrappedType.kind === 180 /* RestType */ || unwrappedType.kind === 185 /* ParenthesizedType */) { - if (unwrappedType.kind === 179 /* OptionalType */) { + while (unwrappedType.kind === 180 /* OptionalType */ || unwrappedType.kind === 181 /* RestType */ || unwrappedType.kind === 186 /* ParenthesizedType */) { + if (unwrappedType.kind === 180 /* OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 180 /* RestType */) { + else if (unwrappedType.kind === 181 /* RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; @@ -134436,7 +137460,7 @@ var ts; ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code, - ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2.code, + ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2.code, // for JSX class components ts.Diagnostics.No_overload_matches_this_call.code, // for JSX FC @@ -134483,6 +137507,12 @@ var ts; } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } + else if (ts.isQualifiedName(parent) && parent.right === node) { + var symbol = checker.getSymbolAtLocation(parent.left); + if (symbol && symbol.flags & 1536 /* Module */) { + suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol); + } + } else if (ts.isImportSpecifier(parent) && parent.name === node) { ts.Debug.assertNode(node, ts.isIdentifier, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); @@ -134706,19 +137736,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 246 /* VariableDeclaration */: - case 159 /* Parameter */: - case 195 /* BindingElement */: - case 162 /* PropertyDeclaration */: - case 285 /* PropertyAssignment */: + case 249 /* VariableDeclaration */: + case 160 /* Parameter */: + case 198 /* BindingElement */: + case 163 /* PropertyDeclaration */: + case 288 /* PropertyAssignment */: return declaration.initializer; - case 277 /* JsxAttribute */: + case 280 /* JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 286 /* ShorthandPropertyAssignment */: - case 161 /* PropertySignature */: - case 288 /* EnumMember */: - case 328 /* JSDocPropertyTag */: - case 322 /* JSDocParameterTag */: + case 289 /* ShorthandPropertyAssignment */: + case 162 /* PropertySignature */: + case 291 /* EnumMember */: + case 333 /* JSDocPropertyTag */: + case 326 /* JSDocParameterTag */: return undefined; } } @@ -134904,7 +137934,7 @@ var ts; function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 218 /* ClassExpression */) { + if (classDeclaration.kind === 221 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -134956,7 +137986,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 213 /* BinaryExpression */) { + if (token.parent.parent.kind === 216 /* BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); @@ -134995,7 +138025,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(146 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(147 /* StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -135046,7 +138076,7 @@ var ts; */ var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 132 /* StringLike */); + return !!(type && type.flags & 402653316 /* StringLike */); }); var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined); changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.factory.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember))), { @@ -135570,7 +138600,7 @@ var ts; if (!isValidCharacter(character)) { return; } - var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(character, preferences) + "}"; + var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(sourceFile, preferences, character) + "}"; changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -135712,7 +138742,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(151 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -135728,7 +138758,7 @@ var ts; return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 229 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 232 /* VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -135753,14 +138783,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 159 /* Parameter */: - case 158 /* TypeParameter */: + case 160 /* Parameter */: + case 159 /* TypeParameter */: return true; - case 246 /* VariableDeclaration */: { + case 249 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 236 /* ForOfStatement */: - case 235 /* ForInStatement */: + case 239 /* ForOfStatement */: + case 238 /* ForInStatement */: return true; } } @@ -135792,12 +138822,10 @@ var ts; } function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { if (isFixAll === void 0) { isFixAll = false; } - if (mayDeleteParameter(p, checker, isFixAll)) { - if (p.modifiers && p.modifiers.length > 0 - && (!ts.isIdentifier(p.name) || ts.FindAllReferences.Core.isSymbolReferencedInFile(p.name, checker, sourceFile))) { - p.modifiers.forEach(function (modifier) { - changes.deleteModifier(sourceFile, modifier); - }); + if (mayDeleteParameter(checker, sourceFile, p, isFixAll)) { + if (p.modifiers && p.modifiers.length > 0 && + (!ts.isIdentifier(p.name) || ts.FindAllReferences.Core.isSymbolReferencedInFile(p.name, checker, sourceFile))) { + p.modifiers.forEach(function (modifier) { return changes.deleteModifier(sourceFile, modifier); }); } else { changes.delete(sourceFile, p); @@ -135805,29 +138833,28 @@ var ts; } } } - function mayDeleteParameter(p, checker, isFixAll) { - var parent = p.parent; + function mayDeleteParameter(checker, sourceFile, parameter, isFixAll) { + var parent = parameter.parent; switch (parent.kind) { - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 165 /* Constructor */: - case 248 /* FunctionDeclaration */: + case 166 /* Constructor */: + return true; + case 251 /* FunctionDeclaration */: { + if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { + return isLastParameter(parent, parameter, isFixAll); + } return true; - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: { + } + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. - var parameters = parent.parameters; - var index = parameters.indexOf(p); - ts.Debug.assert(index !== -1, "The parameter should already be in the list"); - return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 78 /* Identifier */ && !p.symbol.isReferenced; }) - : index === parameters.length - 1; - } - case 167 /* SetAccessor */: + return isLastParameter(parent, parameter, isFixAll); + case 168 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -135842,6 +138869,19 @@ var ts; } }); } + function isCallbackLike(checker, sourceFile, name) { + return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(name, checker, sourceFile, function (reference) { + return ts.isIdentifier(reference) && ts.isCallExpression(reference.parent) && reference.parent.arguments.indexOf(reference) >= 0; + }); + } + function isLastParameter(func, parameter, isFixAll) { + var parameters = func.parameters; + var index = parameters.indexOf(parameter); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); + return isFixAll ? + parameters.slice(index + 1).every(function (p) { return ts.isIdentifier(p.name) && !p.symbol.isReferenced; }) : + index === parameters.length - 1; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -135876,7 +138916,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 231 /* IfStatement */: + case 234 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -135887,8 +138927,8 @@ var ts; return; } // falls through - case 233 /* WhileStatement */: - case 234 /* ForStatement */: + case 236 /* WhileStatement */: + case 237 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -135961,7 +139001,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 301 /* JSDocNullableType */) { + if (typeNode.kind === 305 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -135981,7 +139021,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 301 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 305 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -135998,22 +139038,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 221 /* AsExpression */: - case 168 /* CallSignature */: - case 169 /* ConstructSignature */: - case 248 /* FunctionDeclaration */: - case 166 /* GetAccessor */: - case 170 /* IndexSignature */: - case 189 /* MappedType */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 159 /* Parameter */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: - case 167 /* SetAccessor */: - case 251 /* TypeAliasDeclaration */: - case 203 /* TypeAssertionExpression */: - case 246 /* VariableDeclaration */: + case 224 /* AsExpression */: + case 169 /* CallSignature */: + case 170 /* ConstructSignature */: + case 251 /* FunctionDeclaration */: + case 167 /* GetAccessor */: + case 171 /* IndexSignature */: + case 190 /* MappedType */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 160 /* Parameter */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 168 /* SetAccessor */: + case 254 /* TypeAliasDeclaration */: + case 206 /* TypeAssertionExpression */: + case 249 /* VariableDeclaration */: return true; default: return false; @@ -136115,14 +139155,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 97 /* FunctionKeyword */, sourceFile); break; - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -136201,7 +139241,7 @@ var ts; else { ts.Debug.fail("fixPropertyOverrideAccessor codefix got unexpected error code " + code); } - return codefix.generateAccessorFromProperty(file, startPosition, endPosition, context, ts.Diagnostics.Generate_get_and_set_accessors.message); + return codefix.generateAccessorFromProperty(file, context.program, startPosition, endPosition, context, ts.Diagnostics.Generate_get_and_set_accessors.message); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -136455,7 +139495,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 161 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 162 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -136504,14 +139544,14 @@ var ts; return !!merged; }); }); var tag = ts.factory.createJSDocComment(comments.join("\n"), ts.factory.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); - var jsDocNode = parent.kind === 206 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var jsDocNode = parent.kind === 209 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } codefix.addJSDocTags = addJSDocTags; function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 162 /* PropertyDeclaration */) { + if (signature.parent.kind === 163 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -136521,14 +139561,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 322 /* JSDocParameterTag */: { + case 326 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 323 /* JSDocReturnTag */: + case 327 /* JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -136553,18 +139593,18 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 165 /* Constructor */: + case 166 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 132 /* ConstructorKeyword */, sourceFile); break; - case 206 /* ArrowFunction */: - case 205 /* FunctionExpression */: + case 209 /* ArrowFunction */: + case 208 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 248 /* FunctionDeclaration */: - case 164 /* MethodDeclaration */: + case 251 /* FunctionDeclaration */: + case 165 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -136706,24 +139746,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 212 /* PostfixUnaryExpression */: + case 215 /* PostfixUnaryExpression */: usage.isNumber = true; break; - case 211 /* PrefixUnaryExpression */: + case 214 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 281 /* CaseClause */: - case 282 /* DefaultClause */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 200 /* CallExpression */: - case 201 /* NewExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -136731,20 +139771,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 285 /* PropertyAssignment */: - case 286 /* ShorthandPropertyAssignment */: + case 288 /* PropertyAssignment */: + case 289 /* ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 162 /* PropertyDeclaration */: + case 163 /* PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 246 /* VariableDeclaration */: { + case 249 /* VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -136839,7 +139879,7 @@ var ts; else if (otherOperandType.flags & 296 /* NumberLike */) { usage.isNumber = true; } - else if (otherOperandType.flags & 132 /* StringLike */) { + else if (otherOperandType.flags & 402653316 /* StringLike */) { usage.isString = true; } else if (otherOperandType.flags & 1 /* Any */) { @@ -136866,7 +139906,7 @@ var ts; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 246 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 249 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); @@ -136894,7 +139934,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 200 /* CallExpression */) { + if (parent.kind === 203 /* CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -137337,8 +140377,8 @@ var ts; var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 161 /* PropertySignature */: - case 162 /* PropertyDeclaration */: + case 162 /* PropertySignature */: + case 163 /* PropertyDeclaration */: var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { @@ -137352,8 +140392,8 @@ var ts; /*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: { + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -137382,8 +140422,8 @@ var ts; } break; } - case 163 /* MethodSignature */: - case 164 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 165 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -137429,7 +140469,7 @@ var ts; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0); - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 164 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 165 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -137678,8 +140718,8 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function generateAccessorFromProperty(file, start, end, context, _actionName) { - var fieldInfo = getAccessorConvertiblePropertyAtPosition(file, start, end); + function generateAccessorFromProperty(file, program, start, end, context, _actionName) { + var fieldInfo = getAccessorConvertiblePropertyAtPosition(file, program, start, end); if (!fieldInfo || !fieldInfo.info) return undefined; var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); @@ -137702,7 +140742,7 @@ var ts; fieldModifiers = createModifiers(prepareModifierFlagsForField(modifierFlags)); } } - updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); + updateFieldDeclaration(changeTracker, file, declaration, type, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); insertAccessor(changeTracker, file, getAccessor, declaration, container); @@ -137751,7 +140791,7 @@ var ts; modifierFlags |= 8 /* Private */; return modifierFlags; } - function getAccessorConvertiblePropertyAtPosition(file, start, end, considerEmptySpans) { + function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) { if (considerEmptySpans === void 0) { considerEmptySpans = true; } var node = ts.getTokenAtPosition(file, start); var cursorRequest = start === end && considerEmptySpans; @@ -137781,8 +140821,8 @@ var ts; info: { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), - type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 159 /* Parameter */ ? declaration.parent.parent : declaration.parent, + type: getDeclarationType(declaration, program), + container: declaration.kind === 160 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -137810,17 +140850,17 @@ var ts; ts.factory.createExpressionStatement(ts.factory.createAssignment(createAccessorAccessExpression(fieldName, isStatic, container), ts.factory.createIdentifier("value"))) ], /*multiLine*/ true)); } - function updatePropertyDeclaration(changeTracker, file, declaration, fieldName, modifiers) { - var property = ts.factory.updatePropertyDeclaration(declaration, declaration.decorators, modifiers, fieldName, declaration.questionToken || declaration.exclamationToken, declaration.type, declaration.initializer); + function updatePropertyDeclaration(changeTracker, file, declaration, type, fieldName, modifiers) { + var property = ts.factory.updatePropertyDeclaration(declaration, declaration.decorators, modifiers, fieldName, declaration.questionToken || declaration.exclamationToken, type, declaration.initializer); changeTracker.replaceNode(file, declaration, property); } function updatePropertyAssignmentDeclaration(changeTracker, file, declaration, fieldName) { var assignment = ts.factory.updatePropertyAssignment(declaration, fieldName, declaration.initializer); changeTracker.replacePropertyAssignment(file, declaration, assignment); } - function updateFieldDeclaration(changeTracker, file, declaration, fieldName, modifiers) { + function updateFieldDeclaration(changeTracker, file, declaration, type, fieldName, modifiers) { if (ts.isPropertyDeclaration(declaration)) { - updatePropertyDeclaration(changeTracker, file, declaration, fieldName, modifiers); + updatePropertyDeclaration(changeTracker, file, declaration, type, fieldName, modifiers); } else if (ts.isPropertyAssignment(declaration)) { updatePropertyAssignmentDeclaration(changeTracker, file, declaration, fieldName); @@ -137853,6 +140893,18 @@ var ts; } }); } + function getDeclarationType(declaration, program) { + var typeNode = ts.getTypeAnnotationNode(declaration); + if (ts.isPropertyDeclaration(declaration) && typeNode && declaration.questionToken) { + var typeChecker = program.getTypeChecker(); + var type = typeChecker.getTypeFromTypeNode(typeNode); + if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { + var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; + return ts.factory.createUnionTypeNode(__spreadArrays(types, [ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)])); + } + } + return typeNode; + } function getAllSupers(decl, checker) { var res = []; while (decl) { @@ -137906,7 +140958,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 200 /* CallExpression */ : 201 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 203 /* CallExpression */ : 204 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -138025,7 +141077,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(149 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types)); @@ -138240,7 +141292,7 @@ var ts; function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 99 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 192 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.parent.kind === 195 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -138372,7 +141424,8 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(141 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(142 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.factory.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); @@ -138562,6 +141615,90 @@ var ts; /* @internal */ var ts; (function (ts) { + var codefix; + (function (codefix) { + var fixName = "addVoidToPromise"; + var fixId = "addVoidToPromise"; + var errorCodes = [ + ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + fixIds: [fixId], + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span, context.program); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixName, changes, ts.Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId, ts.Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)]; + } + }, + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag, context.program, new ts.Set()); }); + } + }); + function makeChange(changes, sourceFile, span, program, seen) { + var node = ts.getTokenAtPosition(sourceFile, span.start); + if (!ts.isIdentifier(node) || !ts.isCallExpression(node.parent) || node.parent.expression !== node || node.parent.arguments.length !== 0) + return; + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(node); + // decl should be `new Promise((<decl>) => {})` + var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; + if (!decl || !ts.isParameter(decl) || !ts.isNewExpression(decl.parent.parent)) + return; + // no need to make this change if we have already seen this parameter. + if (seen === null || seen === void 0 ? void 0 : seen.has(decl)) + return; + seen === null || seen === void 0 ? void 0 : seen.add(decl); + var typeArguments = getEffectiveTypeArguments(decl.parent.parent); + if (ts.some(typeArguments)) { + // append ` | void` to type argument + var typeArgument = typeArguments[0]; + var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(113 /* VoidKeyword */)]).types[0]); + if (needsParens) { + changes.insertText(sourceFile, typeArgument.pos, "("); + } + changes.insertText(sourceFile, typeArgument.end, needsParens ? ") | void" : " | void"); + } + else { + // make sure the Promise is type is untyped (i.e., `unknown`) + var signature = checker.getResolvedSignature(node.parent); + var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0]; + var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent); + if (ts.isInJSFile(decl)) { + if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) { + // give the expression a type + changes.insertText(sourceFile, decl.parent.parent.end, ")"); + changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise<void>} */("); + } + } + else { + if (!parameterType || parameterType.flags & 2 /* Unknown */) { + // add `void` type argument + changes.insertText(sourceFile, decl.parent.parent.expression.end, "<void>"); + } + } + } + } + function getEffectiveTypeArguments(node) { + var _a; + if (ts.isInJSFile(node)) { + if (ts.isParenthesizedExpression(node.parent)) { + var jsDocType = (_a = ts.getJSDocTypeTag(node.parent)) === null || _a === void 0 ? void 0 : _a.typeExpression.type; + if (jsDocType && ts.isTypeReferenceNode(jsDocType) && ts.isIdentifier(jsDocType.typeName) && ts.idText(jsDocType.typeName) === "Promise") { + return jsDocType.typeArguments; + } + } + } + else { + return node.typeArguments; + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { var refactor; (function (refactor) { var refactorName = "Convert export"; @@ -138608,16 +141745,16 @@ var ts; return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } switch (exportNode.kind) { - case 248 /* FunctionDeclaration */: - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: - case 252 /* EnumDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 253 /* ModuleDeclaration */: { + case 251 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: + case 255 /* EnumDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 256 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { info: { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } } : undefined; } - case 229 /* VariableStatement */: { + case 232 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -138645,22 +141782,23 @@ var ts; else { var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 92 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 248 /* FunctionDeclaration */: - case 249 /* ClassDeclaration */: - case 250 /* InterfaceDeclaration */: + case 251 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 253 /* InterfaceDeclaration */: changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(87 /* DefaultKeyword */)); break; - case 229 /* VariableStatement */: - // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` - if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { + case 232 /* VariableStatement */: + // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` + var decl = ts.first(exportNode.declarationList.declarations); + if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.Debug.checkDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); + changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.Debug.checkDefined(decl.initializer, "Initializer was previously known to be present"))); break; } // falls through - case 252 /* EnumDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 253 /* ModuleDeclaration */: + case 255 /* EnumDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 256 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); @@ -138687,18 +141825,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 262 /* ImportSpecifier */: - case 267 /* ExportSpecifier */: { + case 265 /* ImportSpecifier */: + case 270 /* ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 259 /* ImportClause */: { + case 262 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -138707,7 +141845,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 260 /* NamespaceImport */) { + else if (namedBindings.kind === 263 /* NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; @@ -138728,11 +141866,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 262 /* ImportSpecifier */: { + case 265 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -138745,7 +141883,7 @@ var ts; } break; } - case 267 /* ExportSpecifier */: { + case 270 /* ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -138779,8 +141917,8 @@ var ts; if (!i) return ts.emptyArray; if (i.error === undefined) { - var description = i.info.kind === 260 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.info.kind === 260 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.info.kind === 263 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.info.kind === 263 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; } if (context.preferences.provideRefactorNotApplicableReason) { @@ -138819,7 +141957,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 260 /* NamespaceImport */) { + if (toConvert.kind === 263 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -138990,7 +142128,6 @@ var ts; if (!finalExpression || checker.isNullableType(checker.getTypeAtLocation(finalExpression))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_convertible_access_expression) }; } - ; if ((ts.isPropertyAccessExpression(condition) || ts.isIdentifier(condition)) && getMatchingStart(condition, finalExpression.expression)) { return { info: { finalExpression: finalExpression, occurrences: [condition], expression: expression } }; @@ -139037,23 +142174,25 @@ var ts; * Returns subchain if chain begins with subchain syntactically. */ function getMatchingStart(chain, subchain) { - return (ts.isIdentifier(subchain) || ts.isPropertyAccessExpression(subchain)) && - chainStartsWith(chain, subchain) ? subchain : undefined; + if (!ts.isIdentifier(subchain) && !ts.isPropertyAccessExpression(subchain) && !ts.isElementAccessExpression(subchain)) { + return undefined; + } + return chainStartsWith(chain, subchain) ? subchain : undefined; } /** * Returns true if chain begins with subchain syntactically. */ function chainStartsWith(chain, subchain) { // skip until we find a matching identifier. - while (ts.isCallExpression(chain) || ts.isPropertyAccessExpression(chain)) { - var subchainName = ts.isPropertyAccessExpression(subchain) ? subchain.name.getText() : subchain.getText(); - if (ts.isPropertyAccessExpression(chain) && chain.name.getText() === subchainName) + while (ts.isCallExpression(chain) || ts.isPropertyAccessExpression(chain) || ts.isElementAccessExpression(chain)) { + if (getTextOfChainNode(chain) === getTextOfChainNode(subchain)) break; chain = chain.expression; } - // check that the chains match at each access. Call chains in subchain are not valid. - while (ts.isPropertyAccessExpression(chain) && ts.isPropertyAccessExpression(subchain)) { - if (chain.name.getText() !== subchain.name.getText()) + // check that the chains match at each access. Call chains in subchain are not valid. + while ((ts.isPropertyAccessExpression(chain) && ts.isPropertyAccessExpression(subchain)) || + (ts.isElementAccessExpression(chain) && ts.isElementAccessExpression(subchain))) { + if (getTextOfChainNode(chain) !== getTextOfChainNode(subchain)) return false; chain = chain.expression; subchain = subchain.expression; @@ -139061,6 +142200,18 @@ var ts; // check if we have reached a final identifier. return ts.isIdentifier(chain) && ts.isIdentifier(subchain) && chain.getText() === subchain.getText(); } + function getTextOfChainNode(node) { + if (ts.isIdentifier(node) || ts.isStringOrNumericLiteralLike(node)) { + return node.getText(); + } + if (ts.isPropertyAccessExpression(node)) { + return getTextOfChainNode(node.name); + } + if (ts.isElementAccessExpression(node)) { + return getTextOfChainNode(node.argumentExpression); + } + return undefined; + } /** * Find the least ancestor of the input node that is a valid type for extraction and contains the input span. */ @@ -139113,7 +142264,7 @@ var ts; return getFinalExpressionInChain(node.left); } // foo && |foo.bar()()| - nested calls are treated like further accesses. - else if ((ts.isPropertyAccessExpression(node) || ts.isCallExpression(node)) && !ts.isOptionalChain(node)) { + else if ((ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) || ts.isCallExpression(node)) && !ts.isOptionalChain(node)) { return node; } return undefined; @@ -139122,7 +142273,7 @@ var ts; * Creates an access chain from toConvert with '?.' accesses at expressions appearing in occurrences. */ function convertOccurrences(checker, toConvert, occurrences) { - if (ts.isPropertyAccessExpression(toConvert) || ts.isCallExpression(toConvert)) { + if (ts.isPropertyAccessExpression(toConvert) || ts.isElementAccessExpression(toConvert) || ts.isCallExpression(toConvert)) { var chain = convertOccurrences(checker, toConvert.expression, occurrences); var lastOccurrence = occurrences.length > 0 ? occurrences[occurrences.length - 1] : undefined; var isOccurrence = (lastOccurrence === null || lastOccurrence === void 0 ? void 0 : lastOccurrence.getText()) === toConvert.expression.getText(); @@ -139138,6 +142289,11 @@ var ts; ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) : ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name); } + else if (ts.isElementAccessExpression(toConvert)) { + return isOccurrence ? + ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) : + ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression); + } } return toConvert; } @@ -139145,7 +142301,7 @@ var ts; var finalExpression = info.finalExpression, occurrences = info.occurrences, expression = info.expression; var firstOccurrence = occurrences[occurrences.length - 1]; var convertedChain = convertOccurrences(checker, finalExpression, occurrences); - if (convertedChain && (ts.isPropertyAccessExpression(convertedChain) || ts.isCallExpression(convertedChain))) { + if (convertedChain && (ts.isPropertyAccessExpression(convertedChain) || ts.isElementAccessExpression(convertedChain) || ts.isCallExpression(convertedChain))) { if (ts.isBinaryExpression(expression)) { changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain); } @@ -139190,27 +142346,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 163 /* MethodSignature */: { + case 164 /* MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 164 /* MethodDeclaration */: { + case 165 /* MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 168 /* CallSignature */: { + case 169 /* CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 165 /* Constructor */: { + case 166 /* Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 169 /* ConstructSignature */: { + case 170 /* ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 248 /* FunctionDeclaration */: { + case 251 /* FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -139262,12 +142418,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 163 /* MethodSignature */: - case 164 /* MethodDeclaration */: - case 168 /* CallSignature */: - case 165 /* Constructor */: - case 169 /* ConstructSignature */: - case 248 /* FunctionDeclaration */: + case 164 /* MethodSignature */: + case 165 /* MethodDeclaration */: + case 169 /* CallSignature */: + case 166 /* Constructor */: + case 170 /* ConstructSignature */: + case 251 /* FunctionDeclaration */: return true; } return false; @@ -139630,20 +142786,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 162 /* PropertyDeclaration */) { + if (current.kind === 163 /* PropertyDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 159 /* Parameter */) { + else if (current.kind === 160 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 165 /* Constructor */) { + if (ctorOrMethod.kind === 166 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 164 /* MethodDeclaration */) { + else if (current.kind === 165 /* MethodDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -139686,7 +142842,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 246 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 249 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! @@ -139698,13 +142854,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; + case 266 /* ExportAssignment */: + (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); + return true; case 105 /* SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 200 /* CallExpression */) { + if (node.parent.kind === 203 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -139716,7 +142875,7 @@ var ts; rangeFacts |= RangeFacts.UsesThis; } break; - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -139730,39 +142889,39 @@ var ts; } }); // falls through - case 249 /* ClassDeclaration */: - case 248 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 251 /* FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 218 /* ClassExpression */: - case 205 /* FunctionExpression */: - case 164 /* MethodDeclaration */: - case 165 /* Constructor */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: + case 221 /* ClassExpression */: + case 208 /* FunctionExpression */: + case 165 /* MethodDeclaration */: + case 166 /* Constructor */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 231 /* IfStatement */: + case 234 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 244 /* TryStatement */: + case 247 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 227 /* Block */: - if (node.parent && node.parent.kind === 244 /* TryStatement */ && node.parent.finallyBlock === node) { + case 230 /* Block */: + if (node.parent && node.parent.kind === 247 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 282 /* DefaultClause */: - case 281 /* CaseClause */: + case 285 /* DefaultClause */: + case 284 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -139774,19 +142933,19 @@ var ts; break; } switch (node.kind) { - case 186 /* ThisType */: + case 187 /* ThisType */: case 107 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 242 /* LabeledStatement */: { + case 245 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 238 /* BreakStatement */: - case 237 /* ContinueStatement */: { + case 241 /* BreakStatement */: + case 240 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -139795,20 +142954,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 238 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 241 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 210 /* AwaitExpression */: + case 213 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 216 /* YieldExpression */: + case 219 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -139862,7 +143021,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 159 /* Parameter */) { + if (current.kind === 160 /* Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -139873,7 +143032,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 294 /* SourceFile */) { + if (current.kind === 297 /* SourceFile */) { return scopes; } } @@ -139963,32 +143122,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 165 /* Constructor */: + case 166 /* Constructor */: return "constructor"; - case 205 /* FunctionExpression */: - case 248 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : ts.ANONYMOUS; - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return "arrow function"; - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 166 /* GetAccessor */: + case 167 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 167 /* SetAccessor */: + case 168 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 249 /* ClassDeclaration */ + return scope.kind === 252 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 254 /* ModuleBlock */ + return scope.kind === 257 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -140214,9 +143373,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 149 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 150 /* UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(149 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)]); } } /** @@ -140245,7 +143404,7 @@ var ts; if (rangeFacts & RangeFacts.InStaticRegion) { modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(141 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(142 /* ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -140277,7 +143436,7 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 230 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 233 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( @@ -140296,7 +143455,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 230 /* ExpressionStatement */) { + if (node.parent.kind === 233 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -140623,7 +143782,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: new ts.Map(), typeParameterUsages: new ts.Map(), substitutions: new ts.Map() }); substitutionsPerScope.push(new ts.Map()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 248 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 251 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -140942,30 +144101,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 288 /* EnumMember */: + case 291 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 258 /* ImportDeclaration */ && - parent.kind !== 262 /* ImportSpecifier */; - case 217 /* SpreadElement */: - case 193 /* ObjectBindingPattern */: - case 195 /* BindingElement */: + return parent.kind !== 261 /* ImportDeclaration */ && + parent.kind !== 265 /* ImportSpecifier */; + case 220 /* SpreadElement */: + case 196 /* ObjectBindingPattern */: + case 198 /* BindingElement */: return false; case 78 /* Identifier */: - return parent.kind !== 195 /* BindingElement */ && - parent.kind !== 262 /* ImportSpecifier */ && - parent.kind !== 267 /* ExportSpecifier */; + return parent.kind !== 198 /* BindingElement */ && + parent.kind !== 265 /* ImportSpecifier */ && + parent.kind !== 270 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 227 /* Block */: - case 294 /* SourceFile */: - case 254 /* ModuleBlock */: - case 281 /* CaseClause */: + case 230 /* Block */: + case 297 /* SourceFile */: + case 257 /* ModuleBlock */: + case 284 /* CaseClause */: return true; default: return false; @@ -141098,7 +144257,7 @@ var ts; if (symbol) { var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { - result.push(declaration); + ts.pushIfUnique(result, declaration); } } } @@ -141140,16 +144299,18 @@ var ts; /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.factory.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, ts.ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true); - changes.replaceNode(file, selection, ts.factory.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.factory.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + changes.replaceNode(file, selection, ts.factory.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.factory.createTypeReferenceNode(id.name, /* typeArguments */ undefined); })), { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.ExcludeWhitespace }); } function doInterfaceChange(changes, file, name, info) { + var _a; var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; var newTypeNode = ts.factory.createInterfaceDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters, /* heritageClauses */ undefined, typeElements); + ts.setTextRange(newTypeNode, (_a = typeElements[0]) === null || _a === void 0 ? void 0 : _a.parent); changes.insertNodeBefore(file, firstStatement, ts.ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true); - changes.replaceNode(file, selection, ts.factory.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.factory.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + changes.replaceNode(file, selection, ts.factory.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.factory.createTypeReferenceNode(id.name, /* typeArguments */ undefined); })), { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.ExcludeWhitespace }); } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; @@ -141179,10 +144340,10 @@ var ts; getEditsForAction: function (context, actionName) { if (!context.endPosition) return undefined; - var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.startPosition, context.endPosition); + var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.program, context.startPosition, context.endPosition); if (!info || !info.info) return undefined; - var edits = ts.codefix.generateAccessorFromProperty(context.file, context.startPosition, context.endPosition, context, actionName); + var edits = ts.codefix.generateAccessorFromProperty(context.file, context.program, context.startPosition, context.endPosition, context, actionName); if (!edits) return undefined; var renameFilename = context.file.fileName; @@ -141194,7 +144355,7 @@ var ts; getAvailableActions: function (context) { if (!context.endPosition) return ts.emptyArray; - var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.startPosition, context.endPosition, context.triggerReason === "invoked"); + var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.program, context.startPosition, context.endPosition, context.triggerReason === "invoked"); if (!info) return ts.emptyArray; if (!info.error) { @@ -141280,7 +144441,6 @@ var ts; changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences)); addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host)); } - // Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file. function getStatementsToMove(context) { var rangeToMove = getRangeToMove(context); if (rangeToMove === undefined) @@ -141288,20 +144448,27 @@ var ts; var all = []; var ranges = []; var toMove = rangeToMove.toMove, afterLast = rangeToMove.afterLast; - ts.getRangesWhere(toMove, function (s) { return !isPureImport(s); }, function (start, afterEndIndex) { + ts.getRangesWhere(toMove, isAllowedStatementToMove, function (start, afterEndIndex) { for (var i = start; i < afterEndIndex; i++) all.push(toMove[i]); ranges.push({ first: toMove[start], afterLast: afterLast }); }); return all.length === 0 ? undefined : { all: all, ranges: ranges }; } + function isAllowedStatementToMove(statement) { + // Filters imports and prologue directives out of the range of statements to move. + // Imports will be copied to the new file anyway, and may still be needed in the old file. + // Prologue directives will be copied to the new file and should be left in the old file. + return !isPureImport(statement) && !ts.isPrologueDirective(statement); + ; + } function isPureImport(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return true; - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -141323,9 +144490,10 @@ var ts; } function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) { var checker = program.getTypeChecker(); + var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective); if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) { deleteMovedStatements(oldFile, toMove.ranges, changes); - return toMove.all; + return __spreadArrays(prologueDirectives, toMove.all); } var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator; var quotePreference = ts.getQuotePreference(oldFile, preferences); @@ -141339,11 +144507,11 @@ var ts; var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference); var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax); if (imports.length && body.length) { - return __spreadArrays(imports, [ + return __spreadArrays(prologueDirectives, imports, [ 4 /* NewLineTrivia */ ], body); } - return __spreadArrays(imports, body); + return __spreadArrays(prologueDirectives, imports, body); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -141396,12 +144564,12 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 258 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 260 /* NamespaceImport */ ? + case 261 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 263 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return node.name; - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); @@ -141432,20 +144600,20 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 258 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 257 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 261 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 260 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -141515,15 +144683,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -141536,7 +144704,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 260 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 263 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -141548,7 +144716,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 261 /* NamedImports */) { + else if (namedBindings.kind === 264 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -141566,9 +144734,9 @@ var ts; changes.delete(sourceFile, name); } break; - case 194 /* ArrayBindingPattern */: + case 197 /* ArrayBindingPattern */: break; - case 193 /* ObjectBindingPattern */: + case 196 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -141695,14 +144863,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 257 /* ImportEqualsDeclaration */: - case 262 /* ImportSpecifier */: - case 259 /* ImportClause */: - case 260 /* NamespaceImport */: + case 260 /* ImportEqualsDeclaration */: + case 265 /* ImportSpecifier */: + case 262 /* ImportClause */: + case 263 /* NamespaceImport */: return true; - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 195 /* BindingElement */: + case 198 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -141714,7 +144882,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 258 /* ImportDeclaration */: { + case 261 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -141724,9 +144892,9 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 246 /* VariableDeclaration */: { + case 249 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -141735,7 +144903,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 260 /* NamespaceImport */) { + if (namedBindings.kind === 263 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -141747,9 +144915,9 @@ var ts; switch (name.kind) { case 78 /* Identifier */: return keep(name) ? name : undefined; - case 194 /* ArrayBindingPattern */: + case 197 /* ArrayBindingPattern */: return name; - case 193 /* ObjectBindingPattern */: { + case 196 /* ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -141806,13 +144974,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 248 /* FunctionDeclaration */: - case 249 /* ClassDeclaration */: - case 253 /* ModuleDeclaration */: - case 252 /* EnumDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 250 /* InterfaceDeclaration */: - case 257 /* ImportEqualsDeclaration */: + case 251 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 256 /* ModuleDeclaration */: + case 255 /* EnumDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: + case 260 /* ImportEqualsDeclaration */: return true; default: return false; @@ -141820,17 +144988,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 248 /* FunctionDeclaration */: - case 249 /* ClassDeclaration */: - case 253 /* ModuleDeclaration */: - case 252 /* EnumDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 250 /* InterfaceDeclaration */: - case 257 /* ImportEqualsDeclaration */: + case 251 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: + case 256 /* ModuleDeclaration */: + case 255 /* EnumDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: + case 260 /* ImportEqualsDeclaration */: return cb(statement); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 230 /* ExpressionStatement */: { + case 233 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -141842,8 +145010,8 @@ var ts; switch (name.kind) { case 78 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 194 /* ArrayBindingPattern */: - case 193 /* ObjectBindingPattern */: + case 197 /* ArrayBindingPattern */: + case 196 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); @@ -141854,9 +145022,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 246 /* VariableDeclaration */: + case 249 /* VariableDeclaration */: return d.parent.parent; - case 195 /* BindingElement */: + case 198 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -141889,23 +145057,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.factory.createModifier(92 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 251 /* TypeAliasDeclaration */: + case 254 /* TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 250 /* InterfaceDeclaration */: + case 253 /* InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); @@ -141916,18 +145084,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 248 /* FunctionDeclaration */: - case 249 /* ClassDeclaration */: + case 251 /* FunctionDeclaration */: + case 252 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 253 /* ModuleDeclaration */: - case 252 /* EnumDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 250 /* InterfaceDeclaration */: - case 257 /* ImportEqualsDeclaration */: + case 256 /* ModuleDeclaration */: + case 255 /* EnumDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: + case 260 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); @@ -142232,15 +145400,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 200 /* CallExpression */: - case 201 /* NewExpression */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -142250,7 +145418,7 @@ var ts; } break; // x["foo"](...) - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -142269,14 +145437,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 198 /* PropertyAccessExpression */: + case 201 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 199 /* ElementAccessExpression */: + case 202 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -142318,11 +145486,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 165 /* Constructor */: + case 166 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -142330,8 +145498,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -142481,7 +145649,7 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; @@ -142489,7 +145657,7 @@ var ts; // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 87 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 218 /* ClassExpression */: + case 221 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -142500,25 +145668,25 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 248 /* FunctionDeclaration */: + case 251 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 87 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 164 /* MethodDeclaration */: + case 165 /* MethodDeclaration */: return [functionDeclaration.name]; - case 165 /* Constructor */: + case 166 /* Constructor */: var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 132 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 218 /* ClassExpression */) { + if (functionDeclaration.parent.kind === 221 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 205 /* FunctionExpression */: + case 208 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; @@ -142594,10 +145762,18 @@ var ts; return node.operatorToken.kind !== 62 /* EqualsToken */; } function getParentBinaryExpression(expr) { - while (ts.isBinaryExpression(expr.parent) && isNotEqualsOperator(expr.parent)) { - expr = expr.parent; - } - return expr; + var container = ts.findAncestor(expr.parent, function (n) { + switch (n.kind) { + case 201 /* PropertyAccessExpression */: + case 202 /* ElementAccessExpression */: + return false; + case 216 /* BinaryExpression */: + return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); + default: + return "quit"; + } + }); + return container || expr; } function isStringConcatenationValid(node) { var _a = treeToArray(node), containsString = _a.containsString, areOperatorsValid = _a.areOperatorsValid; @@ -142946,8 +146122,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 298 /* FirstJSDocNode */ || kid.kind > 328 /* LastJSDocNode */; }); - return child.kind < 156 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 301 /* FirstJSDocNode */ || kid.kind > 333 /* LastJSDocNode */; }); + return child.kind < 157 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -142958,7 +146134,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 156 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 157 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -143016,7 +146192,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(329 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(334 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -143127,13 +146303,13 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 166 /* GetAccessor */: + case 167 /* GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = ts.emptyArray; this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 167 /* SetAccessor */: + case 168 /* SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = ts.emptyArray; this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); @@ -143354,7 +146530,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 294 /* SourceFile */; + _this.kind = 297 /* SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -143413,10 +146589,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 248 /* FunctionDeclaration */: - case 205 /* FunctionExpression */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: + case 251 /* FunctionDeclaration */: + case 208 /* FunctionExpression */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -143436,31 +146612,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 249 /* ClassDeclaration */: - case 218 /* ClassExpression */: - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: - case 252 /* EnumDeclaration */: - case 253 /* ModuleDeclaration */: - case 257 /* ImportEqualsDeclaration */: - case 267 /* ExportSpecifier */: - case 262 /* ImportSpecifier */: - case 259 /* ImportClause */: - case 260 /* NamespaceImport */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 176 /* TypeLiteral */: + case 252 /* ClassDeclaration */: + case 221 /* ClassExpression */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: + case 255 /* EnumDeclaration */: + case 256 /* ModuleDeclaration */: + case 260 /* ImportEqualsDeclaration */: + case 270 /* ExportSpecifier */: + case 265 /* ImportSpecifier */: + case 262 /* ImportClause */: + case 263 /* NamespaceImport */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 177 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 159 /* Parameter */: + case 160 /* Parameter */: // Only consider parameter properties if (!ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 246 /* VariableDeclaration */: - case 195 /* BindingElement */: { + case 249 /* VariableDeclaration */: + case 198 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -143471,12 +146647,12 @@ var ts; } } // falls through - case 288 /* EnumMember */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 291 /* EnumMember */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: addDeclaration(node); break; - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -143489,7 +146665,7 @@ var ts; } } break; - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -143501,7 +146677,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 260 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -143510,7 +146686,7 @@ var ts; } } break; - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -144165,12 +147341,12 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 198 /* PropertyAccessExpression */: - case 156 /* QualifiedName */: + case 201 /* PropertyAccessExpression */: + case 157 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); case 107 /* ThisKeyword */: - case 186 /* ThisType */: + case 187 /* ThisType */: case 105 /* SuperKeyword */: return true; default: @@ -144255,7 +147431,7 @@ var ts; * This is a semantic operation. */ function getSignatureHelpItems(fileName, position, _a) { - var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; + var _b = _a === void 0 ? ts.emptyOptions : _a, triggerReason = _b.triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); @@ -144272,15 +147448,15 @@ var ts; return undefined; } switch (node.kind) { - case 198 /* PropertyAccessExpression */: - case 156 /* QualifiedName */: + case 201 /* PropertyAccessExpression */: + case 157 /* QualifiedName */: case 10 /* StringLiteral */: case 94 /* FalseKeyword */: case 109 /* TrueKeyword */: case 103 /* NullKeyword */: case 105 /* SuperKeyword */: case 107 /* ThisKeyword */: - case 186 /* ThisType */: + case 187 /* ThisType */: case 78 /* Identifier */: break; // Cant create the text span @@ -144297,7 +147473,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 253 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 256 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -144329,21 +147505,33 @@ var ts; var kind = ts.getScriptKind(fileName, host); return kind === 3 /* TS */ || kind === 4 /* TSX */; } - function getSemanticClassifications(fileName, span) { + function getSemanticClassifications(fileName, span, format) { if (!isTsOrTsxFile(fileName)) { // do not run semantic classification on non-ts-or-tsx files return []; } synchronizeHostData(); - return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); + var responseFormat = format || "original" /* Original */; + if (responseFormat === "2020" /* TwentyTwenty */) { + return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); + } + else { + return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); + } } - function getEncodedSemanticClassifications(fileName, span) { + function getEncodedSemanticClassifications(fileName, span, format) { if (!isTsOrTsxFile(fileName)) { // do not run semantic classification on non-ts-or-tsx files return { spans: [], endOfLineState: 0 /* None */ }; } synchronizeHostData(); - return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); + var responseFormat = format || "original" /* Original */; + if (responseFormat === "original" /* Original */) { + return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); + } + else { + return ts.classifier.v2020.getEncodedSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); + } } function getSyntacticClassifications(fileName, span) { // doesn't use compiler - no need to synchronize with host @@ -144524,6 +147712,10 @@ var ts; } // Push all text changes. for (var i = firstLine; i <= lastLine; i++) { + // If the range is multiline and ends on a beginning of a line, don't comment/uncomment. + if (firstLine !== lastLine && lineStarts[i] === textRange.end) { + continue; + } var lineTextStart = lineTextStarts.get(i.toString()); // If the line is not an empty line; otherwise no-op. if (lineTextStart !== undefined) { @@ -145002,7 +148194,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 269 /* ExternalModuleReference */ || + node.parent.kind === 272 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -145020,13 +148212,13 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 157 /* ComputedPropertyName */) { + if (node.parent.kind === 158 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 78 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 197 /* ObjectLiteralExpression */ || node.parent.parent.kind === 278 /* JsxAttributes */) && + (node.parent.parent.kind === 200 /* ObjectLiteralExpression */ || node.parent.parent.kind === 281 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -145068,7 +148260,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 199 /* ElementAccessExpression */ && + node.parent.kind === 202 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -145148,114 +148340,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 229 /* VariableStatement */: + case 232 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 246 /* VariableDeclaration */: - case 162 /* PropertyDeclaration */: - case 161 /* PropertySignature */: + case 249 /* VariableDeclaration */: + case 163 /* PropertyDeclaration */: + case 162 /* PropertySignature */: return spanInVariableDeclaration(node); - case 159 /* Parameter */: + case 160 /* Parameter */: return spanInParameterDeclaration(node); - case 248 /* FunctionDeclaration */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 165 /* Constructor */: - case 205 /* FunctionExpression */: - case 206 /* ArrowFunction */: + case 251 /* FunctionDeclaration */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 166 /* Constructor */: + case 208 /* FunctionExpression */: + case 209 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 227 /* Block */: + case 230 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 254 /* ModuleBlock */: + case 257 /* ModuleBlock */: return spanInBlock(node); - case 284 /* CatchClause */: + case 287 /* CatchClause */: return spanInBlock(node.block); - case 230 /* ExpressionStatement */: + case 233 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 239 /* ReturnStatement */: + case 242 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 233 /* WhileStatement */: + case 236 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 232 /* DoStatement */: + case 235 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 245 /* DebuggerStatement */: + case 248 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 231 /* IfStatement */: + case 234 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 242 /* LabeledStatement */: + case 245 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 238 /* BreakStatement */: - case 237 /* ContinueStatement */: + case 241 /* BreakStatement */: + case 240 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 234 /* ForStatement */: + case 237 /* ForStatement */: return spanInForStatement(node); - case 235 /* ForInStatement */: + case 238 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 236 /* ForOfStatement */: + case 239 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 241 /* SwitchStatement */: + case 244 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 281 /* CaseClause */: - case 282 /* DefaultClause */: + case 284 /* CaseClause */: + case 285 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 244 /* TryStatement */: + case 247 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 243 /* ThrowStatement */: + case 246 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 263 /* ExportAssignment */: + case 266 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 257 /* ImportEqualsDeclaration */: + case 260 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 258 /* ImportDeclaration */: + case 261 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 264 /* ExportDeclaration */: + case 267 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 249 /* ClassDeclaration */: - case 252 /* EnumDeclaration */: - case 288 /* EnumMember */: - case 195 /* BindingElement */: + case 252 /* ClassDeclaration */: + case 255 /* EnumDeclaration */: + case 291 /* EnumMember */: + case 198 /* BindingElement */: // span on complete node return textSpan(node); - case 240 /* WithStatement */: + case 243 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 160 /* Decorator */: + case 161 /* Decorator */: return spanInNodeArray(parent.decorators); - case 193 /* ObjectBindingPattern */: - case 194 /* ArrayBindingPattern */: + case 196 /* ObjectBindingPattern */: + case 197 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 250 /* InterfaceDeclaration */: - case 251 /* TypeAliasDeclaration */: + case 253 /* InterfaceDeclaration */: + case 254 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -145285,7 +148477,7 @@ var ts; case 82 /* CatchKeyword */: case 95 /* FinallyKeyword */: return spanInNextNode(node); - case 155 /* OfKeyword */: + case 156 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -145298,13 +148490,13 @@ var ts; // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern if ((node.kind === 78 /* Identifier */ || - node.kind === 217 /* SpreadElement */ || - node.kind === 285 /* PropertyAssignment */ || - node.kind === 286 /* ShorthandPropertyAssignment */) && + node.kind === 220 /* SpreadElement */ || + node.kind === 288 /* PropertyAssignment */ || + node.kind === 289 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 213 /* BinaryExpression */) { + if (node.kind === 216 /* BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -145326,22 +148518,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 232 /* DoStatement */: + case 235 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 160 /* Decorator */: + case 161 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 234 /* ForStatement */: - case 236 /* ForOfStatement */: + case 237 /* ForStatement */: + case 239 /* ForOfStatement */: return textSpan(node); - case 213 /* BinaryExpression */: + case 216 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 206 /* ArrowFunction */: + case 209 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -145350,21 +148542,21 @@ var ts; } } switch (node.parent.kind) { - case 285 /* PropertyAssignment */: + case 288 /* PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 203 /* TypeAssertionExpression */: + case 206 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 246 /* VariableDeclaration */: - case 159 /* Parameter */: { + case 249 /* VariableDeclaration */: + case 160 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -145372,7 +148564,7 @@ var ts; } break; } - case 213 /* BinaryExpression */: { + case 216 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -145402,7 +148594,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 235 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 238 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -145414,7 +148606,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 236 /* ForOfStatement */) { + parent.parent.kind === 239 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -145455,7 +148647,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 249 /* ClassDeclaration */ && functionDeclaration.kind !== 165 /* Constructor */); + (functionDeclaration.parent.kind === 252 /* ClassDeclaration */ && functionDeclaration.kind !== 166 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -145478,26 +148670,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 253 /* ModuleDeclaration */: + case 256 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 233 /* WhileStatement */: - case 231 /* IfStatement */: - case 235 /* ForInStatement */: + case 236 /* WhileStatement */: + case 234 /* IfStatement */: + case 238 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 234 /* ForStatement */: - case 236 /* ForOfStatement */: + case 237 /* ForStatement */: + case 239 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 247 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 250 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -145522,21 +148714,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 219 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 195 /* BindingElement */) { + if (bindingPattern.parent.kind === 198 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 194 /* ArrayBindingPattern */ && node.kind !== 193 /* ObjectBindingPattern */); - var elements = node.kind === 196 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 219 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 197 /* ArrayBindingPattern */ && node.kind !== 196 /* ObjectBindingPattern */); + var elements = node.kind === 199 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -145544,18 +148736,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 213 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 216 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 252 /* EnumDeclaration */: + case 255 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 249 /* ClassDeclaration */: + case 252 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 255 /* CaseBlock */: + case 258 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -145563,25 +148755,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 254 /* ModuleBlock */: + case 257 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 252 /* EnumDeclaration */: - case 249 /* ClassDeclaration */: + case 255 /* EnumDeclaration */: + case 252 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 227 /* Block */: + case 230 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 284 /* CatchClause */: + case 287 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 255 /* CaseBlock */: + case 258 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -145589,7 +148781,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 193 /* ObjectBindingPattern */: + case 196 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -145605,7 +148797,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 194 /* ArrayBindingPattern */: + case 197 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -145620,12 +148812,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 232 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 200 /* CallExpression */ || - node.parent.kind === 201 /* NewExpression */) { + if (node.parent.kind === 235 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 203 /* CallExpression */ || + node.parent.kind === 204 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 204 /* ParenthesizedExpression */) { + if (node.parent.kind === 207 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -145634,21 +148826,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 205 /* FunctionExpression */: - case 248 /* FunctionDeclaration */: - case 206 /* ArrowFunction */: - case 164 /* MethodDeclaration */: - case 163 /* MethodSignature */: - case 166 /* GetAccessor */: - case 167 /* SetAccessor */: - case 165 /* Constructor */: - case 233 /* WhileStatement */: - case 232 /* DoStatement */: - case 234 /* ForStatement */: - case 236 /* ForOfStatement */: - case 200 /* CallExpression */: - case 201 /* NewExpression */: - case 204 /* ParenthesizedExpression */: + case 208 /* FunctionExpression */: + case 251 /* FunctionDeclaration */: + case 209 /* ArrowFunction */: + case 165 /* MethodDeclaration */: + case 164 /* MethodSignature */: + case 167 /* GetAccessor */: + case 168 /* SetAccessor */: + case 166 /* Constructor */: + case 236 /* WhileStatement */: + case 235 /* DoStatement */: + case 237 /* ForStatement */: + case 239 /* ForOfStatement */: + case 203 /* CallExpression */: + case 204 /* NewExpression */: + case 207 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -145658,20 +148850,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 285 /* PropertyAssignment */ || - node.parent.kind === 159 /* Parameter */) { + node.parent.kind === 288 /* PropertyAssignment */ || + node.parent.kind === 160 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 203 /* TypeAssertionExpression */) { + if (node.parent.kind === 206 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 232 /* DoStatement */) { + if (node.parent.kind === 235 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -145679,7 +148871,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 236 /* ForOfStatement */) { + if (node.parent.kind === 239 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -147254,7 +150446,7 @@ var ts; } else { type = operatorOrType; - operator = 137 /* KeyOfKeyword */; + operator = 138 /* KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -147432,7 +150624,7 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 294 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + return ts.setTextRangePosEnd(kind === 297 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : kind === 78 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : kind === 79 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : @@ -147461,7 +150653,7 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 203 /* TypeAssertionExpression */; + return node.kind === 206 /* TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", |